Created
July 12, 2019 17:22
-
-
Save seleniumgists/0c33c1fc0ca3beaafc3b3fd86c118fee to your computer and use it in GitHub Desktop.
generated automatically from #selenium on seleniumhq slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setField(By locator, String text) { | |
waitForElementPresent(locator, 5); | |
waitForElementEnabled(locator); | |
WebElement element = findElement(locator); | |
highlightTextFieldElement(element, locator); | |
logger.log("Setting [" + locator.toString() + "] to (" + text + ")"); | |
if (element != null) { | |
try { | |
element.clear(); | |
element.sendKeys(text); | |
} catch (Exception e) { | |
logger.log("first try to set field failed, trying again."); | |
element = findElement(locator); | |
element.clear(); | |
element.sendKeys(text); | |
} | |
} else { | |
throwNewWebElementNotFoundExceptionWithMessageAndDiagnostics( | |
"Could not find field element identified by: " + locator.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment