geckodriver icon indicating copy to clipboard operation
geckodriver copied to clipboard

Unable to click on a <tr> element with multiple cells as children

Open hqbrice opened this issue 7 years ago • 14 comments

System

  • Version: 0.20
  • Platform: Windows 10 & CentOS 7
  • Firefox: 59
  • Selenium: 3.11.0

HTML Code

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Titre</title>
    </head>

    <body>
    <div>
		<table style="width: 448px;">
			<thead>
				<tr>
					<th style="width:28px"></th>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<tr role="option" class="focus" id="FONCTION_1">
					<td>L1</td>
					<td>Code 1</td>
				</tr>
				<tr role="option" id="FONCTION_2">
					<td>L2</td>
					<td>Code 2</td>
				</tr>
				<tr role="option" id="FONCTION_3">
					<td>L3</td>
					<td>Code 3</td>
				</tr>
				<tr role="option" id="FONCTION_4">
					<td>L4</td>
					<td>Code 4</td>
				</tr>
			</tbody>
		</table>
			
	</div>
    </body>
</html>

JAVA Code

WebElement row = webDriver().findElement(By.id("FONCTION_1")); row.click();

Stacktrace

org.openqa.selenium.ElementNotInteractableException: Element

could not be scrolled into view Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z' System info: host: 'WS-R0-BR01', ip: '10.1.19.184', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91' Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 59.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 2616, moz:profile: C:\Users\admin\AppData\Loca..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: XP, platformName: XP, platformVersion: 6.1, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, webdriver.remote.sessionid: 0f623bdf-2bbd-4a14-a87b-902...} Session ID: 0f623bdf-2bbd-4a14-a87b-9028e4345874 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) 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.RemoteWebDriver.execute(RemoteWebDriver.java:545) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279) at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83) at integration.testscase.cm.psa.TestAccesMenuPSA2.testAccesMenuPSA(TestAccesMenuPSA2.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Trace-level log

1521817862622 webdriver::server DEBUG <- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"Web DriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickEl ement@chrome://marionette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/lis tener.js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"}} 1521817897810 webdriver::server DEBUG -> POST /session/b3e4baec-d604-4b2d-b65c-07aba9e17b4f/element/5a4fcfc9-01c4-44fb-aa94-60345d579045/click {"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"} 1521817897810 geckodriver::marionette TRACE -> 67:[0,10,"clickElement",{"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"}] 1521817897802 Marionette TRACE 0 -> [0,10,"clickElement",{"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"}] 1521817897816 Marionette TRACE 0 <- [1,10,{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled int ... avigate@chrome://marionette/content/listener. js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"},null] 1521817897825 geckodriver::marionette TRACE <- [1,10,{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"WebDriverError@chrome: //marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickElement@chrome://mari onette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/listener.js:416:13\ncl ickElement@chrome://marionette/content/listener.js:1224:5\n"},null] 1521817897825 webdriver::server DEBUG <- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"Web DriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickEl ement@chrome://marionette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/lis tener.js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"}} 1521817862622 webdriver::server DEBUG <- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"Web DriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickEl ement@chrome://marionette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/lis tener.js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"}} 1521817897810 webdriver::server DEBUG -> POST /session/b3e4baec-d604-4b2d-b65c-07aba9e17b4f/element/5a4fcfc9-01c4-44fb-aa94-60345d579045/click {"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"} 1521817897810 geckodriver::marionette TRACE -> 67:[0,10,"clickElement",{"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"}] 1521817897802 Marionette TRACE 0 -> [0,10,"clickElement",{"id":"5a4fcfc9-01c4-44fb-aa94-60345d579045"}] 1521817897816 Marionette TRACE 0 <- [1,10,{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled int ... avigate@chrome://marionette/content/listener. js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"},null] 1521817897825 geckodriver::marionette TRACE <- [1,10,{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"WebDriverError@chrome: //marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickElement@chrome://mari onette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/listener.js:416:13\ncl ickElement@chrome://marionette/content/listener.js:1224:5\n"},null] 1521817897825 webdriver::server DEBUG <- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <tr id="FONCTION_1" class="focus"> could not be scrolled into view","stacktrace":"Web DriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:160:11\ninteraction.clickEl ement@chrome://marionette/content/interaction.js:131:11\nclickElement/<@chrome://marionette/content/listener.js:1225:14\nnavigate/<@chrome://marionette/content/listener.js:417:13\nnavigate@chrome://marionette/content/lis tener.js:416:13\nclickElement@chrome://marionette/content/listener.js:1224:5\n"}}

hqbrice avatar Mar 23 '18 15:03 hqbrice

Does this work if you click on either TD element?

jmcook74 avatar Mar 23 '18 18:03 jmcook74

Yes it is. But I need to click on tr element for compatibility and in my case some td elements are not visible. In waiting fixing I loop on td while an exception is thrown

hqbrice avatar Mar 23 '18 19:03 hqbrice

I was wondering if it was a similar issue to mine, but it's not. I hope you find a resolution fast. My issue is the page is wrapping my last TD to the next line. The driver thinks the element is not on the screen. I get the same exception. I should probably create a ticket.

jmcook74 avatar Mar 23 '18 20:03 jmcook74

Effectively your problem is not the same. Thanks

hqbrice avatar Mar 23 '18 21:03 hqbrice

Basically the underlying issue is Firefox related and tracked as https://bugzilla.mozilla.org/show_bug.cgi?id=1413493. In https://bugzilla.mozilla.org/show_bug.cgi?id=1406505 I added a workaround for that by letting Marionette default to the first contained cell. I wonder why this is not working here.

whimboo avatar Mar 26 '18 11:03 whimboo

OK. What do you need to understand why this is not working here ?

hqbrice avatar Mar 26 '18 11:03 hqbrice

I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1448825 for that. Thanks for reporting.

whimboo avatar Mar 26 '18 11:03 whimboo

This bug still exists. I just stumbled across it. Is it not being fixed? Or is there a workaround?

Michel73 avatar Jan 14 '21 17:01 Michel73

@Michel73 Seems to be low on their priority list. A workaround I have found is using the Actions object:

action.moveToElement(e).click().perform();

As far as I can tell, it's only needed for TR elements specifically

therichardroberts avatar Jan 14 '21 17:01 therichardroberts

I'm using WebdriverIO. I already tried e = $('tr'); e.moveTo(); e.click() with no success.

Michel73 avatar Jan 14 '21 17:01 Michel73

Right, as I mentioned in the comment, you will need to use the Actions object.

Actions action = new Actions(webdriver); action.moveToElement(e).click().perform();

therichardroberts avatar Jan 14 '21 17:01 therichardroberts

Sorry, I haven't mentioned that I use WebdriverIO with Typescript. There is no such a API, but the error is the same.

Michel73 avatar Jan 14 '21 17:01 Michel73

I am not familiar with Typescript sorry. The only workaround(s) I have found is the one I mentioned and also clicking the

element instead of the element. Hope that helps

therichardroberts avatar Jan 14 '21 17:01 therichardroberts

Thx. My workaround is to select a td within the tr and that works.

Michel73 avatar Jan 14 '21 17:01 Michel73