Selenium Webdriver + Cucumber Demo (Hello world)

Folks,

I am adding some info on how you can create cucumber tests with selenium webdriver.

Just to iterate let me tell you glimpse of cucumber. Else you can search it from google.

Cucumber: 
  • BDD Behavior driven development approach.
Target Audience for such test cases:
  • Stakeholders, Project managers etc, specifically for management team to visualize test activities.
  • It's  used to clarify requirements.
Syntax:
  
Feature: Login to site
 Scenario: Login with valid id and password
    Given user is on index page
    When user goes to index page
    Then Message displayed Login Successfully

Typically it's contain keywords like Feature, Given, When, then etc. We will cover it in next series for more detail info.

Tools & technology:
  • Download all required JAR mentioned here.
  1. Install cucumber to eclipse. Install New Software >> Add name and location http://cucumber.github.com >> Click OK
  2. Below mentioned JAR are required to download from (https://search.maven.org)
    •     cucumber-core
    •     cucumber-java
    •     cucumber-junit
    •     cucumber-jvm-deps
    •     cucumber-reporting
    •     gherkin - gherkin 2.12.2 jar specifically older jar as it works with me with older version.
    •     junit junit
    •     mockito-all
    •     cobertura
  3. Create new java project and add above JAR to project.
  4.  Add new Folder e.g., FeatureTest and add new file >> Mytest.feature. Add above syntax code in this file for example.
  5. Now create new sample class file - Test and add below code.
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "Feature"

)
public class Test { }

Now run it by CTRL + F11 or run it as Junit class and check the response in console.
It should display the  syntax code as output in console.

It should run with Junit test file not with java application. 

I hope it works with you. For any query you can comment/input.

Happy Testing :)



Comments

  1. Selenium is the best tool ever to test an application effectively. Your blog made me to realize that through the best examples you have explained. Thanks for sharing a wonderful article.
    Regards:
    Selenium Training in Chennai | Selenium Training

    ReplyDelete
  2. Thanks for your word. I will keep posting such info thru my blog.

    ReplyDelete

Post a Comment

Popular Posts