ElementNotInteractableException: Element is not reachable by keyboard
Element is not reachable by keyboard in plain words means that the element can’t be reached using the keyboard, which means you won't physically interact with it even.
There can be multiple reasons behind the error Element is not reachable by keyboard which can be either of the following:
- A temporary overlay of some other element over the desired element.
- A permanent overlay of some other element over the desired element.
- Presence of attributes e.g. class="ng-hide", style="display: none", etc
- As per best practices while sending character sequence, you must not attempt to invoke click() or sendKeys() on any <p> or <div> tag, instead invoke click() on the desired <input> tag following the Official locator strategies for the webdriver.
There are different approaches to address this issue.
Incase of temporary overlay use WebDriverWait inconjunction with ExpectedConditions for the desired element to be visible/clickable as follows:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.nsg-button"))).click();
String inputText = "Rozmeen";
WebElement myElement = driver.findElement(By.id("u_0_b"));
String js = "arguments.setAttribute('value','"+inputText+"')"