Reputation: 11
I am looking to integrate Selenium Webdriver with Cucumber. Please let me know if anyone has already implemented the same.
Upvotes: 1
Views: 994
Reputation: 1006
You need the Cucumber-JVM. After that when you write feature files you need to define their steps definitions using Selenium (this could be your POM Based project or direct api call).
Below are links on how to go about implementing this
Links http://cukes.info/install-cucumber-jvm.html
http://cukes.info/running.html
Snippets
Feature Sample
Feature: Page Verification
Scenario: Verify Page
Given User navigated to Page
And user SignUp
Then user should be redirected to Login
When User click "https://page.com/userLogin/"
Then User Should verify "Login"
And close browsers
Steps Definition
public class StepsDefinitions {
WebDriver driver = null;
@Given("^User navigated to \"([^\"]*)\"$")
public void gotoSite(String link) throws Throwable {
driver = new FirefoxDriver();
driver.navigate().to(link);
}
@When("^User click \"([^\"]*)\"$")
public void clickSignUp(String link) throws Throwable {
driver.findElement(By.linkText(link)).click();
}
@Then("^User Should verify \"([^\"]*)\"$")
public void User_Should_verify(String title) {
Assert.assertTrue( driver.getTitle().equals(title));
}
@And("^close browsers$")
public void close_browsers() throws Throwable {
driver.close();
}
Upvotes: 2
Reputation: 1485
I would recommend you to go through the detailed quick set-up instructions in the link.
Resource: Blog Thomas Sundberg
Upvotes: 0