Вы находитесь на странице: 1из 2

Successful Test Automation with Selenium and Cucumber

Selenium and Cucumber are a great combination when it comes to web application
automation, as Cucumber allows you to write your tests quickly in English-like language and
Selenium allows you to run on various combinations of browsers. Let us have a look at some
details on how to put them together.
The Basics
Web application regression testing is done to assess the app compatibility across a range of
browsers, but this method tends to be a burden on both time and money. A better method
would be the use of multiple test suites to be driven across a number of browsers.
The obvious benefit of this approach is that errors and glitches get identified early in the
production pipeline, and can be resolved almost immediately.
When using Selenium with Cucumber for test automation, tests are written in feature files
that can be understood by various stakeholders in an agile environment such as the BAs.
Cucumber also comes with its ability to support multiple scripts and programming languages,
the Selenium API is one that allows to drive the browser.
An overview of the process
Cucumber essentially acts as a common ground between developers and non-technical
stakeholders. The BDD style is used in writing tests, which is easily comprehensible and
doesnt require any deep knowledge of code (basic commands i.e., Given, When, Then).
After the acceptance tests are written into feature files, Cucumber picks the feature steps and

executes the step definitions defined in the respective programming language. The Selenium
WebDriver API can be called in these step definitions to drive the browsers.
More details
Cucumber does not communicate directly with the applications, it needs to be used in
conjunction with tools such as Selenium WebDriver, and Cucumber acts more like an
execution framework. Cucumbers use of English-like language (Gherkin) for its
programming function, test case execution is supported with features and scenarios executed
based on their definitions.
There are 3 steps for writing automated tests that deliver high value while requiring only low
maintenance using Cucumber:
1. Define scenarios: The acceptance tests are written in English-like language called Gherkin.
The scenarios defined are based on the user stories and features defined by the BA team.
Sometimes, the BA also creates the Feature files for use by the testing team.
2. Create step definitions: Once the scenarios are defined, the steps have to be implemented
for execution. This can be done in a variety of different languages supported by Cucumber.
For instance, if a language like Java is selected for implementation, the necessary classes and
methods are defined by creating a project structure. The project can have references added
to the Selenium jars, so that the packages can be imported and used to implement the steps
to drive browsers using Selenium API.
3. Define UI Element descriptions: One of the best ways to define UI element descriptions is
using the PageObject design pattern. PageObject pattern makes automated test
maintenance easier. This is because any changes made to the page elements are abstracted
into the PageObjects itself, without the need to update feature files and step definitions.

Concluding Words
Weve described the working relationship between Selenium and Cucumber here, but there
are of course a number of BDD tools that can be used together for the purpose of building test
automation suites that deliver high value to your business and do not require heavy
maintenance.
Gallop Solutions Specialists in Software Testing
Gallop is a leading provider of software testing solutions. With our vast experience in testing
the web applications, we help our customers to reduce the execution time of testing, leading
to cost-effective solutions. To know more about our testing services contact us today.
Tags: Automation testing with selenium and cucumber, cucumber selenium best practices,
cucumber test automation, cucumber with selenium webdriver, selenium with cucumber, Selenium
with Cucumber for test automation, successful test automation, Web application regression testing

Вам также может понравиться