Skip to content

Instantly share code, notes, and snippets.

@maggandalf
Created April 20, 2011 17:12
Show Gist options
  • Select an option

  • Save maggandalf/931992 to your computer and use it in GitHub Desktop.

Select an option

Save maggandalf/931992 to your computer and use it in GitHub Desktop.
Utils for Selenium.
public class PageUtils {
private WebDriver webDriver;
public void open(String url) {
webDriver.get(url);
}
public void fillFormField(String fieldId, String content) {
WebElement element = webDriver.findElement(id(fieldId));
element.clear();
element.sendKeys(content);
}
public void submitForm(String submitId) {
WebElement element = webDriver.findElement(id(submitId));
element.submit();
}
public String getElementText(String elementId) {
WebElement element = webDriver.findElement(id(elementId));
return element.getText();
}
public void setWebDriver(WebDriver webDriver) {
this.webDriver = webDriver;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment