Selenium Java Interview Questions And Answers – Part 15

Selenium Java Interview Questions And Answers – Part 15

Selenium Java Interview Questions and Answers Part-15

1) What are the difference between Jbehave and Cucumber?

– JBehave is pure Java Framework, and Cucumber is Ruby-based.
– JBehave are based on stories while Cucumber is based on features.

2) Explain when to use Rspec and when to use Cucumber?

Rspec should be used when developers are involved in the process of describing the steps and the binding code. But Cucumber should be used when product owners are responsible for writing the feature files.

3) What is the language used for expressing scenario in feature file ?

Cucumber uses the Gherkin language to define the scenario in feature file using keywords like Given, Then, And, When, etc…

4) Explain what are regular expressions in Cucumber?

Regular expressions are used in Cucumber to link a Gherkin Step with a Step Definition.

5) What Are Before, After, Beforestep And Afterstep Hooks?

– Methods annotated with @Before will execute before every scenario.
– Methods annotated with @BeforeStep execute before every step.
– Methods annotated with @After execute after every scenario.
– Methods annotated with @AfterStep execute after every step.

6) What Are Cucumber Tags? Why We Use The Tags?

Tags are a great way to organise your features and scenarios. They can be used for two purposes:
– Running a subset of scenarios
– Restricting hooks to a subset of scenarios

7) What Is Cucumber Dry Run?

Cucumber dry run is basically used to compile cucumber feature files and step Definitions.
If there is any compilation errors it will show when we use dry run.

8) Explain what is Scenario Outline In Feature File?

Cucumber Scenario Outline is used to execute the same scenario multiple times with different data sets.

9) What Is Step Definition In Cucumber?

Step Definition is a java method that is linked to a step in the scenario in feature file.

10) Explain What is Bdd (Behaviour Driven Development) ?

BDD is an Agile software development process that encourages collaboration among developers, QA and non-technical or business participants in a software project.

11) What are the benefits of Bdd in Selenium ?

– Living Documentation
– Collaboration
– Domain-specific language
– Test Reuse
– Data-driven testing
– Automated tests

12) Define feature file. Mention the components of feature file?

Feature file is a file which consists of scenarios, steps and conditions for different test cases. The following are the components contained by the feature file:
– Feature
– Scenario
– Scenario Outline
– Steps in Given/When/Then format

13) What is the meaning of Steps in Cucumber tool?

Each step starts with Given, When, Then, And, or But. Cucumber executes each step in a scenario one at a time, in the given sequence. When Cucumber tries to execute a step, it looks for a matching step definition to execute.

14) What is the difference between Given, When, Then steps in feature file?

– Given steps are used to describe the initial context of the system – the scene of the scenario.
– When steps are used to describe an event, or an action.
– Then steps are used to describe an expected outcome, or result.

15) What is @CucumberOptions in test runner? List the properties of @CucumberOptions?

Cucumber Options tag is used to provide a link between the feature files and step definition files.
Following are the different properties:
– dryRun: checks if all steps have a step definition
– features: sets the path of the feature file
– glue: sets the path of the step definition files
– tags: instructs what tags should be executed in feature file
– monochrome: display the console output in readable format
– format: sets which reporter formats to use
– strict: will fail execution if there are undefined or pending steps

16) What are the programming languages supported by Cucumber?

Cucumber supports many programming languages like Perl, PHP, Python, .Net and Java

17) How many times scenario outline will be executed?

Scenario outline is run once for each row listed in the Examples section.

18) What is background and when it will be executed?

Background contains one or more Given steps, which are run before each scenario.

19) Explain types of Hooks in Cucumber?

Following are the different types of hooks in cucumber:
– Before
– After
– BeforeStep
– AfterStep

20) What is the pattern of writing Given, When, Then, And, or But?

There is no strict pattern of writing these keywords and can be interchangeably used based on the scenarios.

21) What is the use of glue property under Cucumber Options tag?

The glue is a part of Cucumber options that describes the location and path of the step definition file.

22) What is the difference between cucumber, JBehave, and Specflow?

Cucumber is based on Ruby while Jbehave is a Java based framework and Specflow is a .Net based framework.

23) What are the two main purpose of using Gherkin?

– Documents user scenarios
– Writing an automated test in BDD

24) How to comment a line in Feature file?

To put comments, we just need to start the statement with “#” sign

25) Explain Cucumber Hooks?

Hooks are blocks of code that can run at various points in the Cucumber execution cycle. They are typically used for setup and teardown of the environment before and after each scenario.

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

Open chat
Contact Us on Whatsapp