Home > Net >  Capital letters got rearranged / swapped when using sendKeys() using Selenium
Capital letters got rearranged / swapped when using sendKeys() using Selenium

Time:04-07

I've faced a problem using Selenium and chromedriver. When using sendKeys() method with capitals, letters are rearranged. For example, I use:

element.sendKeys("ABCD")`

but in runtime it sends "CDAB" string.

As far I played with this method, it happens only with CAPITALS.

Does anyone know the reason why?

CodePudding user response:

The text based HTML of the element would have been helpful to debug the issue in a better way.

However, it is always recommened that to send a character sequence to any <input> field you need to induce WebDriverWait to elementToBeClickable() for the element to render completely and you can use the following solution:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("element_cssSelector"))).sendKeys("ABCD");
  • Related