Skip to content

Instantly share code, notes, and snippets.

@brobles82
Created January 30, 2020 00:57
Show Gist options
  • Save brobles82/f893df75dd378a5c60aef64958f73ae2 to your computer and use it in GitHub Desktop.
Save brobles82/f893df75dd378a5c60aef64958f73ae2 to your computer and use it in GitHub Desktop.
public static void type(String text, WebElement webElement) {
if (text == null) {
return;
}
new WebDriverWait(driver(), 30).until((WebDriver) -> {
try {
webElement.clear();
if (webElement.getAttribute("value").length() > 0) {
for(int i=0; i<webElement.getAttribute("value").length; i++) {
webElement.sendKeys(Keys.BACK_SPACE);
}
}
webElement.sendKeys(text);
return webElement.getAttribute("value").equals(text);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment