Explanation of ElementNotInteractableException
Element is not reachable by keyboard
simply means that the element cannot be accessed using the keyboard, making it impossible to interact with it physically.
Possible Causes
There are several reasons why this error might occur:
- The element may be hidden, as modern UI designs often use techniques to hide raw HTML input fields. This could include implementing the
hidden
attribute in various ways:
- An overlay from another element may temporarily cover the desired element.
- An overlay from another element may permanently cover the desired element.
- Attributes such as
class="ng-hide"
, style="display: none"
, etc., may be present.
- It is recommended to avoid using
click()
or sendKeys()
on <p>
or <div>
tags when sending character sequences. Instead, perform these actions on the desired <input>
tag following the Official locator strategies for the webdriver.
Solution Options
There are different methods to resolve this issue:
- For issues related to temporary overlays, utilize WebDriverWait along with ExpectedConditions to ensure the desired element becomes visible/clickable before interacting with it.
- To address problems caused by permanent overlays, use the
executeScript()
method from the JavascriptExecutor interface.
- If attributes like
class="ng-hide"
, style="display: none"
, are causing issues, adjust them using executeScript()
.
Additional References and Updates
For more information, you can refer to the provided references and keep up to date with new developments that may impact the handling of elements that are not interactable by the keyboard.
This Particular Issue on Facebook Login page
In cases where the application, such as Facebook, utilizes dynamic elements like React Native, adjusting your automation scripts based on changing IDs is essential. Consider using a Dynamic Locator Strategy approach to ensure reliable interactions with elements.
// Sample code block for interacting with dynamic elements
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com");
// Perform interactions with dynamic elements
// ...
Stay informed about updates and solutions to common issues that may arise while automating test scenarios involving elements that are not reachable by keyboard.