HomeAutomation

Selenium Java Interview Questions And Answers – Part 17

Selenium Java Interview Questions And Answers – Part 17

Selenium Java Interview Questions and Answers Part-17

1) What is the name of the plugin that is used to integrate Eclipse with Cucumber?

Cucumber Eclipse Plugin can be used in Eclipse to integrate with Cucumber.

2) What is the meaning of TestRunner class in Cucumber?

TestRunner class is the starting point from where the execution starts. It also links with feature files and step definitions.

3) Provide an example of TestRunner class in Cucumber?

@RunWith(Cucumber.class)
@CucumberOptions(
features = {
"src/test/resources/features"
},
plugin = {
"pretty",
"html:target/cucumber.html",
"json:target/cucumber.json"
}

)
public class TestRunner {
}

 

4) What is the starting point of execution for feature files?

TestRunner is the starting point of execution.

5) Should any code be written within TestRunner class?

In a default TestRunner class, no code is required to execute it.

6) Can we use same step definition in different scenarios?

Yes. We can use same step definition in multiple scenarios.

7) What is the maximum number of steps that are to be written within a scenario?

There is no fixed limit of steps within a scenario and it is completely dependent on the application.

8) What software do you need to run a Cucumber Web Test ?

We need any IDE like Eclipse or IntellijIdea and setup a Maven Java Project. Then we need to add maven dependencies for cucumber-jvm, cucumber-core and cucumber-junit. After that we need to add Feature Files, Step Definition Files and Test Runner file to run a cucumber test.

9) Cucumber Execution Starts From Where?

Cucumber execution starts from TestRunner file.

10) On what places you can write tags in feature file?

Tags can be placed above the following elements:
– Feature
– Scenario
– Scenario Outline
– Examples

11) Is It Mandatory To Use The Keywords While Writing Scenario Steps ?

Yes. It is mandatory to use Gherkin keywords while writing scenario steps.

12) How To Generate Cucumber Execution Reports?

Cucumber Execution Reports can be generated by adding plugin to Test Runner file.

@RunWith(Cucumber.class)
@CucumberOptions(
features = {
"src/test/resources/features"
},
plugin = {
"pretty",
"html:target/cucumber.html",
"json:target/cucumber.json"
}
)

 

13) How to run a Particular Scenario from a Feature File ?

We can use cucumber tags to run a particular scenario from a feature file.
– Add tag to scenario

@regression
Scenario: Login Test

 

– Add tags to Test Runner file plugin

@RunWith(Cucumber.class)
@CucumberOptions(
features = {
"src/test/resources/features"
},
plugin = {
"pretty",
"html:target/cucumber.html",
"json:target/cucumber.json",
"tags:@regression"
}
)

 

14) What are the tagged hooks in cucumber?

Tagged Hooks can be used to execute hooks for scenarios with specific tags.

@After("@browser and not @firefox)
public void setup(){
driver.quit();
}

 

15) What is Tag Inheritance in cucumber?

Tags are inherited by all child elements.
Tags that are defined for a feature will be inherited by Scenario, Scenario outline.
Tags that are placed above a Scenario Outline will be inherited by Examples.

16) What are the prerequisites for building a Selenium Cucumber automation framework?

We need to include the relevant maven dependencies for Selenium and Cucumber.

17) What are Data Tables in Cucumber?

Data Tables are used in Examples for Scenario Outline. Scenario will be executed for every row in the data table.

18) What are the cucumber assertions?

Cucumber doesn’t have its own assertion library and we need to use the assertions available in any testing framework like TestNG or Junit.

19) How can any scenario in the feature file be written?

Scenario includes different steps which can be writeen using Given/When/Then/And format.

20) Mention the main reasons behind using a simple programming language such as Gherkin?

Gherkin is used in Cucumber to make it easy for non technical people to understand the scenarios as it is quite similar to English language. Business Analysts can easily convert the business requirements into Features/Scenarios/Steps using Gherkin.

21) What is Cucumber Report? Mention the benefits of Cucumber Report?

Cucumber Report contains details of the test execution like which scenarios passed or failed, what are the steps within the scenarios, and other environment details. This report can be shared with the project stakeholders for reporting purpose.

22) What is the cucumber.yml file in cucumber?

All command line options can be stored in cucumber.yml file and can be placed in project’s root directory.

23) Can we use TestNG with cucumber?

Yes. We can use TestNG with cucumber. For that we need to extend AbstractTestNGCucumberTests Class in Test Runner class.

24) What is the main difference between Scenario and Scenario outline?

– Scenario can be executed only once but Scenario outline can be used to execute scenario multiple times with different sets of data
– Scenario Outline contains Examples with data table but Scenario doesn’t contain examples

25) Write a three line code to show scenario outline?

Scenario Outline: Login to application
Given User enters <username> and <password>
Examples:
| username | password |
| [email protected] | 123 |

 

Next Steps:

> More interview questions and answers on Selenium Java, continue to the next post (Click on Next Post link below)

> Check complete Selenium Java interview questions and answers here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Bijan Patel

Connect to me on Linked In (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

 

 

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp