Home > Blockchain >  clear() method leaves one unknown character in the input field using SeleniumWebdriver
clear() method leaves one unknown character in the input field using SeleniumWebdriver

Time:04-30

When clearing a input field using clear() method for chromedriver version 100.0.4896.127, leaves this special char in the field

This occured only on this chromedriver version.

Anyone else encountered this?

CodePudding user response:

There is a work around solution:

element.sendKeys(Keys.chord(Keys.CONTROL,"a", Keys.DELETE)

Or

while (!inputField.getAttribute("value").equals("")) {
        inputField.sendKeys(Keys.BACK_SPACE);
       }

CodePudding user response:

Ideally while invoking clear() you need to induce WebDriverWait for the elementToBeClickable() as follows:

new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("elementCssSelector"))).clear();
  • Related