SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.74k stars 8.02k forks source link

[🐛 Bug]: Selenium Firefox shadow element is not clicked by webelement.click() #14117

Closed gotomiglecz closed 2 weeks ago

gotomiglecz commented 2 weeks ago

What happened?

There is an element waiting for click behaviour in the shadow dom in depth 4. (element ->shadowroot->element->shadowroot->element->shadowroot->element->shadowroot->element)

Action: (WebElement) element.click() (inside fluentwait.until to make sure it retried) Actual: doesn't do anything while the element is visible in the screen (viewport) Expected: to do the same thing as new Actions().click(element).perform(); would do.

How can we reproduce the issue?

public void trigger() {
        getFluentWait(webDriver())
            .ignoring(NoSuchShadowRootException.class)
            .ignoring(ElementNotInteractableException.class)
            .withMessage("click " + locator())
            .until(d -> {
                final WebElement element = locator()
                    .function()
                    .apply(d)
                    .findAny()
                    .orElseThrow();
                //new Actions(d) //this works almost as it misclicks the preceding element (another bug? due to another shadowroot elements interfering xy calculations?)
                //    .click(element)
                //    .perform();
                element.click(); //this fails
                return true;
            });
    }

Relevant log output

org.openqa.selenium.TimeoutException: Expected condition failed: click css="app-root" -> #shadow-root -> css="chameleon-theme-provider > synapse-error-boundary > synapse-auth" -> #shadow-root -> css="app-layout" -> #shadow-root -> css=".side-nav" -> #shadow-root -> css="nav-button#inventory" (tried for 10 second(s) with 500 milliseconds interval)

    at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:265)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
    at com.gotoresolve.inventory.domain.page.component.Button.trigger(Button.java:38)
    at com.gotoresolve.inventory.domain.page.login.LoginFacade.selectInventoryMenu(LoginFacade.java:47)
    at com.gotoresolve.inventory.domain.page.login.LoginFacade.login(LoginFacade.java:18)
    at com.gotoresolve.inventory.e2e.HelloTest.test1(HelloTest.java:11)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:141)
    at org.testng.internal.invokers.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelper.java:260)
    at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:154)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:274)
    at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:678)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:230)
    at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:63)
    at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:992)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:203)
    at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:154)
    at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:134)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.testng.TestRunner.privateRun(TestRunner.java:739)
    at org.testng.TestRunner.run(TestRunner.java:614)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:421)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:413)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:373)
    at org.testng.SuiteRunner.run(SuiteRunner.java:312)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1274)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1208)
    at org.testng.TestNG.runSuites(TestNG.java:1112)
    at org.testng.TestNG.run(TestNG.java:1079)
    at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:65)
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)
Caused by: org.openqa.selenium.ElementNotInteractableException: Element <nav-button id="inventory" class="extended" name="Inventory"> could not be scrolled into view
Build info: version: '4.21.0', revision: '79ed462ef4'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '21.0.3'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Command: [9ce77662-26a5-4bfd-af66-d041862b9efb, clickElement {id=f8b0a82f-101b-414a-b4fd-15bcc17e7ac8}]
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 126.0.1, moz:accessibilityChecks: false, moz:buildID: 20240526221752, moz:debuggerAddress: 127.0.0.1:39749, moz:geckodriverVersion: 0.34.0, moz:headless: false, moz:platformVersion: 10.0, moz:processID: 15516, moz:profile: C:\Users\lmiglecz\AppData\L..., moz:shutdownTimeout: 60000, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://127.0.0.1:39749/devtoo..., se:cdpVersion: 85.0, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, userAgent: Mozilla/5.0 (Windows NT 10....}
Element: [[org.openqa.selenium.remote.ShadowRoot@97f91f2b] -> css selector: nav-button#inventory]
Session ID: 9ce77662-26a5-4bfd-af66-d041862b9efb
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
    at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:223)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:76)
    at com.gotoresolve.inventory.domain.page.component.Button.lambda$trigger$0(Button.java:47)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:203)
    ... 32 more

Operating System

windows 11 enterprise 23H2 build #22631.3593

Selenium version

4.21.0

What are the browser(s) and version(s) where you see this issue?

Firefox 126.0.1

What are the browser driver(s) and version(s) where you see this issue?

4.21.0 of https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java

Are you using Selenium Grid?

no

github-actions[bot] commented 2 weeks ago

@gotomiglecz, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

titusfortner commented 2 weeks ago

This is the underlying consideration:

Caused by: org.openqa.selenium.ElementNotInteractableException: Element <nav-button id="inventory" class="extended" name="Inventory"> could not be scrolled into view

Geckodriver is calculating it as outside of the viewport. If that's not the case, then you need to provide a reproducible example to Mozilla.

github-actions[bot] commented 2 weeks ago

Hi, @gotomiglecz. This issue has been determined to require fixes in GeckoDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an Issue with the GeckoDriver team.

Feel free to comment the issues that you raise back in this issue. Thank you.