how am I ever going to write any selenium automation code that can have the same outcome everytime and could ever ever ever be trusted? as most of you should know sendKeys is simply shit.
-it doesnt write the complete input
-sometimes it doesnt write at all
-its skips to other elements and messes up the input
-it cant write longer character sequences
-you cant check it correctly
-you cant make it wait.until everything is sent
and this all is simply randomized into a clusterfuck of one-to-a-billion my at this moment examples (I probably changed my approach more than 10 times)
public static void sendKeys(By by, String input) {
if (by == null) {
throw new IllegalArgumentException("Parameter 'by' is null.");
}
if (input == null) {
throw new IllegalArgumentException("Parameter 'input' is null.");
}
LOGGER.info("sendKeys() - By locator '{}'", by.toString());
WebElement elem = WebElementFinder.getElement(by);
elem.clear();
elem.sendKeys(input);
checkKeySendResult(by, input);
}
public static void checkKeySendResult(By by, String input) {
WebElement elem = WebElementFinder.getElement(by);
String value = elem.getAttribute("value");
if (!value.equals(input)) {
LOGGER.info("sendKeys() - didn't work");
elem.clear();
elem.sendKeys(input);
checkKeySendResult(by, input);
} else {
LOGGER.info("sendKeys() - sent all characters");
}
}
you know what I expect;
-all keys should be sent
-sendKeys shouldn't stop midway of typing and then go somewhere else
-I should be able to correctly check if the input is right
-if incorrect, I should be able to correct it easily and unwaveringly
and please dont tell me to use a waiter, cause I obviously did try out waiters in every single step...
I'll test out any kind of advice offered here as I do hope everyone does and hopefully someone can open my eyes to a steady sendKeys method.
if you cant help me, please do use this thread to ragingly describe your hatred towards sendKeys and how frustrating it is to be working with it.
Thank you all for your input.
obs: sorry for my french