How to resolve this error Element not interactable Any solution

0 votes

Nov 22, 2020 in Selenium by faha
• 380 points
70,942 views

Hello @ faha,

Could you please paste your snipper or code so that we can help you out? Your screenshot is not visible!!

package day16;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.Keys;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.ExpectedCondition;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

public class ExplicitWaitDemo {

public static void main(String[] args) throws InterruptedException {

System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver_win32\\chromedriver.exe");

ChromeDriver driver =new ChromeDriver();

driver.get("https://www.google.com/");

driver.manage().window().maximize();

WebDriverWait mywait=new WebDriverWait(driver,40);

driver.findElement(By.name("q")).sendKeys("Selenium");

driver.findElement(By.name("btnK")).sendKeys(Keys.RETURN);

 WebElement ele=mywait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[contains(text(),'SeleniumHQ Browser Automation')]")));

ele.click();

// driver.findElement(By.xpath("//span[contains(text(),'SeleniumHQ Browser Automation')]")).click();

---------------------------------------------------------------------------------------------------------------------------------------------------------

Console window

------------------------------------------------------------------------------------------------------

Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 5259

Only local connections are allowed.

Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.

ChromeDriver was started successfully.

[1606143653.885][WARNING]: This version of ChromeDriver has not been tested with Chrome version 87.

Nov 23, 2020 9:00:55 AM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Detected dialect: W3C

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable

  (Session info: chrome=87.0.4280.66)

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'

System info: host: 'DESKTOP-D0DRPFI', ip: '192.168.1.72', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.1'

Driver info: org.openqa.selenium.chrome.ChromeDriver

Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.66, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\mailf\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56861}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}

Session ID: 36b74c451bf517dcd2dec9903c12e620

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)

at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)

at day16.ExplicitWaitDemo.main(ExplicitWaitDemo.java:27)

-------------------------------------------

1 answer to this question.

0 votes

Hi, @Faha,

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.

Reason

There can be multiple reasons behind the error Element is not reachable by keyboard which can be either of the following:

  • The element is hidden as modern JavaScript-centric UI styles always keep the ugly raw HTML input field hidden. The hidden attribute could have been implemented through either of the following ways:
    • temporary overlay of some other element over the desired element.
    • 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.

Solution

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:

    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    
    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button.nsg-button"))).click();
    
  • In case of permanent overlay use executeScript() method from JavascriptExecutor interface as follows:

    import org.openqa.selenium.JavascriptExecutor;
    
    String inputText = "Rozmeen";
    WebElement myElement = driver.findElement(By.id("u_0_b"));
    String js = "arguments[0].setAttribute('value','"+inputText+"')"
    ((JavascriptExecutor) driver).executeScript(js, myElement);
answered Nov 24, 2020 by Gitika
• 65,890 points
("button.nsg-button")
Ok from where did u get this element?

Hey Gitika

any <p> or <div> tag

I'm  familiar with <div> tags but not with these <p> . By not using these tags to bel clicked.

Invoking desired input<tag>. Can you give any example for it?

What exactly are the official locator strategies of webdriver. Are they using xpath or chropath for every element?

I used temporary overlay method but its giving an error.

import org.openqa.selenium.By;

import org.openqa.selenium.Keys;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

public class ExplicitWati2 {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver_win32\\chromedriver.exe");

ChromeDriver driver =new ChromeDriver();

driver.get("https://www.google.com/");

driver.manage().window().maximize();

driver.findElement(By.name("q")).sendKeys("Selenium");

driver.findElement(By.name("btnK")).sendKeys(Keys.RETURN);

new WebDriverWait.Until(ExpectedConditions.elementToBeClickable(By.cssSelector(button.nsg-button))).click();

Hello, @Faha,

Regarding your detailed query issue, we will get back you within a few hours, do cooperate with us, and in the meantime if it possible from your end to resolve the issue do mention here!!

Hey, @faha,

Regarding your previous issue, I would suggest you look at this https://www.edureka.co/community/55217/resolve-elementnotinteractableexception-selenium-webdriver

How to resolve this error  Element not interactable    Any solution  | Edureka Community
xipgipkywm http://www.g5d9z75q9p7k009t48z2dj43xtsu1l5gs.org/
<a href="http://www.g5d9z75q9p7k009t48z2dj43xtsu1l5gs.org/">axipgipkywm</a>
[url=http://www.g5d9z75q9p7k009t48z2dj43xtsu1l5gs.org/]uxipgipkywm[/url]

Related Questions In Selenium

0 votes
1 answer

How to eliminate this error”Cannot instantiate the type Select in selenium webdriver”

Try below code. Select sc = new Select(driver.findElement(By.xpath("your ...READ MORE

answered May 18, 2018 in Selenium by Samarpit
• 5,910 points
9,946 views
0 votes
1 answer

How to resolve Pycharm Referenced Error with Import Selenium Web driver?

Below will help: Pycharm > Preferences > Project ...READ MORE

answered Jun 26, 2018 in Selenium by Samarpit
• 5,910 points
9,520 views
+1 vote
2 answers
0 votes
0 answers

How to hover element when action class is not working in my Selenium framework ?

When i am writing the code to ...READ MORE

Feb 16, 2019 in Selenium by Raishul
3,901 views
+1 vote
5 answers

Getting this error: “Element is not clickable at point”

There are 3 possible solutions for this: 1. ...READ MORE

answered Apr 21, 2018 in Selenium by king_kenny
• 3,710 points
83,049 views
0 votes
1 answer

Error showing up, Unable to click the second page and get title. Any Solution?

Hi, @Faha, As you access the URL http://demo.automationtesting.in/Windows.html there ...READ MORE

answered Nov 25, 2020 in Selenium by Gitika
• 65,890 points
3,953 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP