{"id":2523,"date":"2015-09-15T09:04:17","date_gmt":"2015-09-15T09:04:17","guid":{"rendered":"http:\/\/www.gallop.net\/blog\/?p=700"},"modified":"2018-10-03T14:36:55","modified_gmt":"2018-10-03T09:06:55","slug":"successful-test-automation-with-selenium-and-cucumber","status":"publish","type":"post","link":"https:\/\/www.cigniti.com\/blog\/successful-test-automation-with-selenium-and-cucumber\/","title":{"rendered":"Successful Test Automation with Selenium and Cucumber"},"content":{"rendered":"

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.<\/p>\n

The Basics<\/strong><\/p>\n

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.<\/p>\n

The obvious benefit of this approach is that errors and glitches get identified early in the production pipeline, and can be resolved almost immediately.<\/p>\n

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 BA\u2019s. Cucumber also comes with its ability to support multiple scripts and programming languages, the Selenium API is one that allows to drive the browser.<\/p>\n

An overview of the process<\/strong><\/p>\n

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 doesn\u2019t 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.<\/p>\n

More details<\/strong><\/p>\n

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. Cucumber\u2019s use of English-like language (Gherkin) for its programming function, test case execution is supported with features and scenarios executed based on their definitions.<\/p>\n

There are 3 steps for writing automated tests that deliver high value while requiring only low maintenance using Cucumber:<\/p>\n

    \n
  1. Define scenarios<\/em>: 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.<\/li>\n
  2. Create step definitions<\/em>: 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.<\/li>\n
  3. Define UI Element descriptions<\/em>: 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.<\/li>\n<\/ol>\n

    Concluding Words<\/strong><\/p>\n

    We\u2019ve described the working relationship between Selenium<\/strong> <\/a>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.<\/p>\n

    Gallop Solutions \u2013 Specialists in Software Testing<\/strong><\/p>\n

    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<\/a> today.<\/p>\n","protected":false},"excerpt":{"rendered":"

    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 […]<\/p>\n","protected":false},"author":2,"featured_media":12982,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[870,999,1000,1001,1525,1526,1618,1765],"ppma_author":[3736],"authors":[{"term_id":3736,"user_id":2,"is_guest":0,"slug":"admin","display_name":"Cigniti Technologies","avatar_url":{"url":"https:\/\/www.cigniti.com\/blog\/wp-content\/uploads\/120X120-1.png","url2x":"https:\/\/www.cigniti.com\/blog\/wp-content\/uploads\/120X120-1.png"},"user_url":"http:\/\/www.cigniti.com\/","last_name":"Technologies","first_name":"Cigniti","job_title":"","description":"Cigniti is the world\u2019s leading AI & IP-led Digital Assurance and Digital Engineering services company with offices in India, the USA, Canada, the UK, the UAE, Australia, South Africa, the Czech Republic, and Singapore. We help companies accelerate their digital transformation journey across various stages of digital adoption and help them achieve market leadership."}],"_links":{"self":[{"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/posts\/2523"}],"collection":[{"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":0,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/media\/12982"}],"wp:attachment":[{"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/tags?post=2523"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.cigniti.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}