Original Source: Tutorial on Selenium, Cucumber and Gherkin
What is SELENIUM In recent times, there are a lot of applications which are web-based and which run in a browser. Testing such applications manually take up much time hence automated testing tools like selenium is the way to go. Selenium is a free open source automated testing tool for web applications across various browsers and platforms. It is actually similar to HP Quick Test Pro only that Selenium converges on automating web-based applications.
What is Many times it happens that clients are nontechnical persons and to make them understand the testing process you need a behavior driven framework. Cucumber is a behavior driven framework which can help you to produce the product as per client needs. It tests the behavior of the application and writes the tests in simple English language which is similar to English and known as Gherkin language.
Prerequisite for using Cucumber with Selenium Selenium jar files: • Selenium-server-standalone Can be downloaded at http://www.seleniumhq.org/download/
Continue… Jar files For Cucumber : • Cucumber-core • Cucumber-html • cobertura code coverage • Cucumber-java • Cucumber-junit • Cucumber-jvm-deps • Cucumber-reporting • Hemcrest-core • Gherkin • Junit Can be downloaded at http:// mvnrepository.com/search?q=Cucumber On this page, you have to search files & download them individually. Let’s go through Some Screenshot!
Continue…
Continue…
Continue…
Automation Testing Using Cucumber with Selenium First of all, create a JAVA project in eclipse by New -> Project -> Other, here you have to select Maven in other projects
Continue‌ Now go to Project > Select Properties > Java Build Path and add all the libraries downloaded earlier
Continue‌ Now create a folder by name "Features" and then create a new file in it by name MyTest.feature. You can write Gherkin syntax in it now.
Continue‌ Write below lines in MyTest.feature file using Gherkin syntax. Feature: Reset functionality on login page of Application Scenario: Verification of Reset button Given Open the Firefox and launch the application When Enter the Username and Password Then Reset the credential
Continue… Now write the selenium testrunner script. Here we create 'TestRunner' package and then 'Runner.java' class file under it.
• @RunWith() is the test runner class to start executing test
• @CucmberOptions() is used to set some properties for cucumber test like feature file, step definition, etc.
Continue‌ Now here we create 'StepDefinition' package and then 'Steps.java' script file under it.
@Given is used to open Firefox and launch the application
@When is used to enter the username and password @Then is used to reset the credential
Continue… Now execute the script and analyze the output.
Conclusion • Cucumber is a recognized BDD tool and it is very simple to write/read and can be read by clients either they are a technical and non-technical person. • Cucumber and Selenium integration can be done using the following 3 steps: • Create a feature file and write tests in Gherkin language. • Then Create Testrunner file and execute this script. • Create Step definition, the real selenium script described under this package. Original Source: Tutorial on Selenium, Cucumber and Gherkin Selenium with Cucumber (BDD Framework): Tutorial with Exam ple
Contact Us Web Call Email
www.nexsoftsys.com
+1-646-971-0799
info@nexsoftsys.com