0

I am able to click that username field but not able to pass the values in that field. Facing the below error.

driver.get("xxxx");
WebDriverWait wait = new WebDriverWait(driver, 60);
WebElement username = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("xxxx")));
username.click();
username.sendKeys("xxxxxxxx");

Error I received -

An unknown server-side error occurred while processing the command. Original error: unknown error: cannot focus element (Session info: chrome=69.0.3497.100)

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
abitha begum
  • 25
  • 1
  • 4

2 Answers2

0

You can use click(), clear() and sendkeys() combination, it worked for me :

username.click(); username.clear(); username.sendkeys("xxxx")

0

This error message...

An unknown server-side error occurred while processing the command. Original error: unknown error: cannot focus element (Session info: chrome=69.0.3497.100)

...implies that the Selenium was unable to focus on the desired element.

To invoke sendKeys() instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • id:

    WebElement username = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.id("xxxx")));
    username.click();
    username.clear();
    username.sendKeys("xxxxxxxx");
    
  • cssSelector:

    WebElement username = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#xxxx")));
    username.click();
    username.clear();
    username.sendKeys("xxxxxxxx");
    
  • xpath:

    WebElement username = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='xxxx']")));
    username.click();
    username.clear();
    username.sendKeys("xxxxxxxx");
    

Additional Considerations

Ensure that:

  • JDK is upgraded to current levels JDK 8u271.
  • Selenium is upgraded to current released Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v87.0 level.
  • Chrome is updated to current Chrome Version 87.0 level. (as per ChromeDriver v87.0 release notes).
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352