Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

WebDriver

aslakhellesoy edited this page May 25, 2011 · 4 revisions

WebDriver (or Selenium 2.0) is a perfect match for Cuke4Duke. You can use it with any of Cuke4Duke’s supported programming languages.

Here is a step definition written in Java:

@When("^I search for \"([^\"]*)\"$")
public void search(String query) {
    WebElement searchField = facade.getBrowser().findElement(By.name("q"));
    searchField.sendKeys(query);
    // WebDriver will find the containing form for us from the searchField element
    searchField.submit();
}

See the Java WebDriver example project for a full example.

-Or maybe you want to use Groovy instead:

When(~"I search for \"(.*)\"") { String query ->
  searchField = browser.findElement(By.name("q"))
  searchField.sendKeys(query)
  // WebDriver will find the containing form for us from the searchField element
  searchField.submit()
}

See the Groovy WebDriver example project for a full example.

Clone this wiki locally