Error org openqa selenium ElementNotInteractableException

0 votes

I have following menu bar which I try to test with selenium web driver:

<div class="text-center">

  <div class="btn-group pull-left">

    <button type="button" class="btn btn-default" id="id-home_prevButton" style="min-height:10px;min-width:10px" hidden="false"><span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span>

    </button><button type="button" class="btn btn-default" id="id-home_nextButton" style="min-height:10px;min-width:10px" hidden="false"><span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span></button>

  </div>

  <span class="span-title" id="id-home_title">Home</span>

  <div class="btn-group pull-right">

    <button type="button" class="btn btn-default" id="id-home_infoButton" hidden="false"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></button>

    <div class="btn-group">

      <button type="button" id="id-home_dropDownButton" class="btn btn-default dropdown-toggle" data-toggle="dropdown" hidden="false">

        <i class="glyphicon glyphicon-align-justify"></i><span class="caret"></span></button>

      <ul class="dropdown-menu dropdown-menu-right simple-title-dropdown" role="menu">

        <li><a href="#home" id="id-home_menu_homeLink">Home</a></li>

      </ul>

    </div>

  </div>

</div>

Button ids are unique.Selenium scala code clicking the button is:

def wEPrint(description: String, wE: WebElement): String = {

  s"$description = wE.getTagName: ${wE.getTagName}  wE.getText: ${wE.getText}  wE.getSize: ${wE.getSize}  wE.isDisplayed: ${wE.isDisplayed}  wE.isEnabled: ${wE.isEnabled}  wE.isSelected: ${wE.isSelected}"

}


...



log.debug("Find id-home_prevButton")


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

val waitPrevButton = new WebDriverWait(driver, 20)

val prevButton = driver.findElement(By.id("id-home_prevButton"))

log.debug(wEPrint("prevButton",prevButton))

waitPrevButton.until(ExpectedConditions.visibilityOfElementLocated(By.id("id-home_prevButton")))

log.debug("id-home_prevButton.click")

prevButton.click()

SBT console output is:

22:49:11.378 [run-main-3] DEBUG com.example.selex.MWLExp$ - Find id-home_prevButton

22:49:11.539 [run-main-3] DEBUG com.example.selex.MWLExp$ - prevButton = wE.getTagName: button  wE.getText:   wE.getSize: (40, 34)  wE.isDisplayed: true  wE.isEnabled: true  wE.isSelected: false

22:49:11.588 [run-main-3] DEBUG com.example.selex.MWLExp$ - id-home_prevButton.click

[error] (run-main-3) org.openqa.selenium.ElementNotInteractableException:

[error] Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

[error] System info: host: 'tra', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-72-generic', java.version: '1.8.0_121'

[error] Driver info: org.openqa.selenium.firefox.FirefoxDriver

[error] Capabilities [{moz:profile=/tmp/rust_mozprofile.T6j4aNCkep6a, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.4.0-72-generic, moz:processID=51151.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

[error] Session ID: 1349d85f-d360-4725-963c-f6ec277e308c

org.openqa.selenium.ElementNotInteractableException:

Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

System info: host: 'tra', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-72-generic', java.version: '1.8.0_121'

Driver info: org.openqa.selenium.firefox.FirefoxDriver

Capabilities [{moz:profile=/tmp/rust_mozprofile.T6j4aNCkep6a, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.4.0-72-generic, moz:processID=51151.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

Session ID: 1349d85f-d360-4725-963c-f6ec277e308c

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

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

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

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

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

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

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

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

    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:82)

    at com.example.selex.MWLExp$.run01(MWLExp.scala:92)

    at simple.MainJVM$.main(DemoJVM.scala:44)

    at simple.MainJVM.main(DemoJVM.scala)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:498)

Selenium test code can find the button, it is displayed and enabled, visibilityOfElementLocated succeeds but clicking throws ElementNotInteractableException.

When I run the app without selenium, button is visible, and I can click it and it works without any errors.

In selenium IDE clicking the button works OK. Selenium IDE Java code for clicking the button is:

driver.findElement(By.id("id-home_prevButton")).click();

EDIT

I modified the code slightly:

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

val waitPrevButton = new WebDriverWait(driver, 20)

val prevButton = driver.findElement(By.id("id-home_prevButton"))

log.debug(wEPrint("prevButton",prevButton))

waitPrevButton.until(ExpectedConditions.visibilityOfElementLocated(By.id("id-home_prevButton")))

log.debug("id-home_prevButton.click")

//prevButton.click()

//prevButton.sendKeys(Keys.RETURN)

prevButton.sendKeys(Keys.ENTER)

And now the exception message is:

23:30:56.497 [run-main-6] DEBUG com.example.selex.MWLExp$ - Find id-home_prevButton

23:30:56.735 [run-main-6] DEBUG com.example.selex.MWLExp$ - prevButton = wE.getTagName: button  wE.getText:   wE.getSize: (40, 34)  wE.isDisplayed: true  wE.isEnabled: true  wE.isSelected: false

23:30:56.798 [run-main-6] DEBUG com.example.selex.MWLExp$ - id-home_prevButton.click

[error] (run-main-6) org.openqa.selenium.ElementNotInteractableException: Element is not visible

[error] Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

[error] System info: host: 'tra', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-72-generic', java.version: '1.8.0_121'

[error] Driver info: org.openqa.selenium.firefox.FirefoxDriver

[error] Capabilities [{moz:profile=/tmp/rust_mozprofile.gBopOPHPUrCL, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.4.0-72-generic, moz:processID=54936.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

[error] Session ID: eba7323c-6412-4ed7-a91f-3f897b3ec83f

org.openqa.selenium.ElementNotInteractableException: Element is not visible

Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

System info: host: 'tra', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-72-generic', java.version: '1.8.0_121'

Driver info: org.openqa.selenium.firefox.FirefoxDriver

Capabilities [{moz:profile=/tmp/rust_mozprofile.gBopOPHPUrCL, rotatable=false, timeouts={implicit=0.0, pageLoad=300000.0, script=30000.0}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0.0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=4.4.0-72-generic, moz:processID=54936.0, browserName=firefox, javascriptEnabled=true, platformName=linux}]

Session ID: eba7323c-6412-4ed7-a91f-3f897b3ec83f

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

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

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

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

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

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

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

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

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

    at com.example.selex.MWLExp$.run01(MWLExp.scala:93)

    at simple.MainJVM$.main(DemoJVM.scala:44)

    at simple.MainJVM.main(DemoJVM.scala)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

So now it says that element is not visible although visibilityOfElementLocated has succeeded and it is displayed and enabled.

What's the reason for this exception and how to fix it?

Jul 30, 2018 in Selenium by Martin
• 4,320 points
7,528 views

1 answer to this question.

0 votes

Try to use javascriptExecutor to click the element by embedding javascript.

WebElement element = driver.findElement(By.id("id-home_prevButton");

((JavascriptExecutor)driver).executeScript("arguments[0].click();", element);
answered Jul 30, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
12,755 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,624 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
6,699 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,561 views
0 votes
2 answers

Selenium Webdriver Error: org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'

Facing Error Exception in thread "main" org.openqa.selenium .WebDriverException: unknown ...READ MORE

answered Mar 5, 2020 in Selenium by anonymous
9,805 views
0 votes
4 answers
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