mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.03k stars 1.51k forks source link

Can't sendKeys on web component input shadow DOM through Selenium #2059

Closed jgreffe closed 1 year ago

jgreffe commented 1 year ago

System

Testcase

Reproduction with https://github.com/jgreffe/mwc-selenium Tests pass with chrome driver, but not with geckodriver.

Stacktrace

Element <mwc-textfield id="textfield-shadow"> is not reachable by keyboard
Build info: version: '4.5.0', revision: 'fe167b119a'
System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.6', java.version: '11.0.15'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Command: [7465e278-9fbb-4054-8267-93e4178831be, sendKeysToElement {id=068259ed-779e-489e-a1b8-32bb6f0f87c2, value=[Ljava.lang.CharSequence;@7c75db8b}]
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 106.0, moz:accessibilityChecks: false, moz:buildID: 20221010110315, moz:debuggerAddress: 127.0.0.1:53135, moz:geckodriverVersion: 0.32.0, moz:headless: false, moz:platformVersion: 21.6.0, moz:processID: 12029, moz:profile: /var/folders/px/nstksjjj4x5..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: MAC, proxy: Proxy(), se:cdp: ws://127.0.0.1:53135/devtoo..., se:cdpVersion: 85.0, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Element: [[FirefoxDriver: firefox on MAC (7465e278-9fbb-4054-8267-93e4178831be)] -> cssSelector: mwc-textfield]
Session ID: 7465e278-9fbb-4054-8267-93e4178831be
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
        at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
        at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
        at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:113)
        at sandbox.AbstractDriverTest.mwc_textfield_shadow(AbstractDriverTest.java:45)

Trace-level log

trace.log

jgreffe commented 1 year ago

Linked to https://github.com/mozilla/geckodriver/issues/1414?

whimboo commented 1 year ago

Thank you for the report. I had a look at the trace log and here the relevant excerpt:

1666715203771   Marionette  DEBUG   0 -> [0,5,"WebDriver:ElementSendKeys",{"id":"b794f94d-0509-4658-9486-484d1376f56f","text":"test","value":["t","e","s","t"]}]
1666715203772   Marionette  DEBUG   0 <- [1,5,{"error":"element not interactable","message":"Element <mwc-textfield id=\"textfield-shadow\"> is not reachable by keybo ... mmandsChild.jsm:504:29\nreceiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:152:31\n"},null]
1666715203772   webdriver::server   DEBUG   <- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <mwc-textfield id=\"textfield-shadow\"> is not reachable by keyboard","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.jsm:12:1\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5\nElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.jsm:302:5\nwebdriverSendKeysToElement@chrome://remote/content/marionette/interaction.js:625:13\ninteraction.sendKeysToElement@chrome://remote/content/marionette/interaction.js:601:11\nsendKeysToElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:504:29\nreceiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.jsm:152:31\n"}}

org.openqa.selenium.ElementNotInteractableException: Element <mwc-textfield id="textfield-shadow"> is not reachable by keyboard

So this is indeed a duplicate of #1414.