Top 16 Selenium Cucumber Interview Questions You Must Prepare 19.Mar.2024

However, the Cucumber and Jbehave share the same perspective, but there are few key differences.

  1. Jbehave is Java-based and Cucumber is Ruby-based.
  2. Jbehave is story-driven whereas the Cucumber is feature-driven.

  1. It supports Safari browser via a third-party driver. It is experimental and comes with limited functionality.
  2. It provides an Android driver to run tests on its native mobile browser.

A feature file in cucumber specifies parameters and conditions for executing the test code. It can combine any of the following.

  1. A feature.
  2. A user scenario.
  3. The scenario outline.
  4. A <Given> clause.
  5. A <When> clause.
  6. A <Then> clause.

We can select the target scenario from a feature file by providing its line number.

cucumber features/test.feature:10 --format html > testfeature.html

We use to compile the cucumber feature files and step definitions. If there occur any compilation errors, then it shows them on the console.

  1. RSpec is more successful in doing unit testing.
  2. As you know that Cucumber is a behaviour-driven development tool. So you can use it for System and Integration testing.

  1. It’s an open source, so you save a lot on the cost side.
  2. It gives you options to choose from a list of programming languages. e.g. Java, Python, C-Sharp, Ruby, and Python.
  3. It offers easy and powerful dom-level testing.
  4. You can use it in either of Agile or waterfall environment.
  5. Easy integration with Jenkins, Bamboo, and some other notable CI tools.

In general, a framework is an entity which binds several modules in a logical sequence to cover the end-to-end flows of an application. The objective of investing into a framework is to test a product which has a recurring roadmap and regular release cycle.

You might like to consider the following facts while creating a productive and scalable test framework.

  1. Identify the type of application you are going to test. Is it a Web app, support mobile devices or runs on a desktop.
  2. Would it require backend testing? e.g. Databases or SDK.
  3. Decide on the input format. Is it static or dynamic?
  4. Do you need to test the app for internationalization?
  5. It must have a report which can help you trace a failure with minimum efforts.
  6. It must support auto-generation of parametrization tests.
  7. Have a config file to define any setup related settings or the global properties.
  8. Apply abstraction at every level to separate the functionality.

Cucumber tags help in filtering the scenarios. We can tag the scenarios and then run them based on tags.

  1. We can add tags to scenarios with <@> symbol.
  2. We can use the following command to run a cucumber tagged scenario.

cucumber features -t @<tag_name>

Example: cucumber features -t @test

  1. You can use Selenium for the functional, regression, and load testing of the web-based applications.
  2. You can employ this tool for doing the post-release validation.
  3. Integrate it with the continuous integration tools like Jenkins, Hudson, QuickBuild or CruiseControl.

The above two questions were a little basic which sometimes we miss explaining during the interview. So, we thought it was worth starting with them.

Following are the possible benefits of using a test framework.

  1. It reduces the complexity of using a variety of technologies inculcated in a product.
  2. It organizes the unit and functional testing efforts of a developer and tester.
  3. Provides early feedback on the quality of the code.
  4. Helps in tracking test coverage as well as code coverage.
  5. Results in easy debugging and reduces chances of errors.

Yes, there are a few we are listing down below. Though, we recommend building one of your own as it gives you more freedom.

  1. Selenium-Cucumber framework for testing the web and android apps.
  2. Another one is an acceptance testing framework using Cucumber and Selenium Webdriver.

  1. Before: executes before the feature file execution.
  2. After: executes after the feature file execution.
  3. BeforeStep: executes before the each step execution.
  4. AfterStep: executes after the each step execution.

We run the following command to produce HTML reports.

cucumber <featurename>.feature --format html --out report.html --format pretty

You can create Cucumber profiles to run a set of features and step definitions. Use the following command to execute a cucumber profile.

cucumber features -p <profile_name>

#Example: cucumber features -p acceptance