WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
223028
SendKeys on Input of type=file returns element not found in some cases
https://bugs.webkit.org/show_bug.cgi?id=223028
Summary
SendKeys on Input of type=file returns element not found in some cases
Allen Moore
Reported
2021-03-10 06:44:39 PST
Created
attachment 422826
[details]
Java project that has tests showing the error. Using SendKeys on an Input of type=file in some cases returns an ElementNotFound exception even though the file upload actually succeeds. driver.findElement(By.id("file-upload")).sendKeys(absolutePath); The attached project has two tests. One is a passing test against a standard input file upload control. The other is a failing test against a 3rd party file upload control where the target input element is not visible to the user. Running the failing test using Chrome or FireFox the test will pass. Running it with Safari will fail. If you debug the test when running against safari and stop immediately after the sendkeys and then observe the target website you will see that file is actually uploaded and attached to the input even though the SendKeys returned the following exception. org.openqa.selenium.NoSuchElementException: For documentation on this error, please visit:
https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: ********, ip: '**********', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.7', java.version: '11.0.10' Driver info: org.openqa.selenium.safari.SafariDriver Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 14.0.3, javascriptEnabled: true, platform: MAC, platformName: MAC, safari:automaticInspection: false, safari:automaticProfiling: false, safari:diagnose: false, safari:platformBuildVersion: 19H524, safari:platformVersion: 10.15.7, safari:useSimulator: false, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}} Session ID: DAAF9550-05E9-4B18-BDF4-4EAC6ABE86F9 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.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 SafariFileUploadBug.failingExample(SafariFileUploadBug.java:63) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) 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.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Attachments
Java project that has tests showing the error.
(1.58 MB, application/zip)
2021-03-10 06:44 PST
,
Allen Moore
no flags
Details
Patch
(5.30 KB, patch)
2021-03-22 17:22 PDT
,
Blaze Burg
hi
: review+
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2021-03-17 07:45:15 PDT
<
rdar://problem/75526126
>
Blaze Burg
Comment 2
2021-03-19 15:57:43 PDT
I'm able to repro this, thanks for the report.
Blaze Burg
Comment 3
2021-03-19 16:02:30 PDT
The underlying issue here is that the <input> is being removed and safaridriver is trying to evaluate some JS to determine what files it has uploaded.
Blaze Burg
Comment 4
2021-03-22 17:22:43 PDT
Created
attachment 423968
[details]
Patch
Devin Rousso
Comment 5
2021-03-24 15:03:43 PDT
Comment on
attachment 423968
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=423968&action=review
r=me :)
> Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp:938 > + Ref<JSON::ArrayOf<String>> selectedFiles = JSON::ArrayOf<String>::create(); > + for (const String& filename : m_filesToSelectForFileUpload)
NIT: `auto`?
Blaze Burg
Comment 6
2021-03-25 11:56:43 PDT
Committed
r275050
(
235765@main
): <
https://commits.webkit.org/235765@main
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug