Status

defect
P1
normal
RESOLVED FIXED
6 years ago
4 years ago

People

(Reporter: ato, Assigned: ato)

Tracking

(Blocks 1 bug, {pi-marionette-server, pi-marionette-spec})

Trunk
mozilla40
Points:
---

Firefox Tracking Flags

(firefox40 fixed)

Details

(Whiteboard: [marionette=1.0])

Attachments

(2 attachments, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Posted file test_file_upload.py
Marionette lacks support for file uploads.  WebDriver uses sendKeys on
<input type=file> elements to set the value to the absolute path of
the file.

When using WebDriver remotely over the wire an additional end-point,
POST /file, is used to temporarily store the file on the remote server
until sendKeys is called a second time, upon which the absolute path
should refer to the remote file instead of the local file.

The resolution from our F2F in Boston was to follow the logic that
sendKeys, by default, appends as it would textual elements.  Provided
the user agent supports the concept of multiple, calling it a second
time would append another file.  If the user agent doesn't understand
this concept, it will replace the set file.

The discussion around the resolution can be found here:

    http://www.w3.org/2013/06/13-testing-minutes.html#item08

See also the spec bug about covering this in the algorithm for sendKeys:

    https://www.w3.org/Bugs/Public/show_bug.cgi?id=23876

See the attached TC for a few tests, which can be executed using
`python runtests.py --binary=/path/to/firefox --type=browser
~/test_file_upload.py`.
Whiteboard: [spec]
(Assignee)

Comment 1

5 years ago
hsteen experimented with this using special powers last night, and was able to come up with a solution:

<hallvors> yay. m.set_context(m.CONTEXT_CHROME) followed by m.execute_script('gBrowser.contentDocument.getElementById("input_type_file_id").value="file.txt" WORKS! I can upload files!
(AFAIK this won't work on Android though - the extension API is different.. In any case using send_keys or a dedicated API should be supported :))
(Assignee)

Comment 3

5 years ago
It also won't work in a B2G context, but leaving Android and B2G as unsupported for the time being should be fine according to :automatedtester.
Whiteboard: [spec] → [marionette=1.0]
Priority: -- → P1
Assignee: nobody → ato
(Assignee)

Updated

4 years ago
OS: Linux → All
Hardware: x86_64 → All
Attachment #8335385 - Attachment mime type: text/x-python → text/plain
(Assignee)

Comment 4

4 years ago
Have a working patch locally.  Need to add tests for uploading to local httpd.
Status: NEW → ASSIGNED
(Assignee)

Comment 5

4 years ago
Posted file MozReview Request: bz://941085/ato (obsolete) —
/r/6359 - Bug 941085: File uploads support in Marionette

Pull down this commit:

hg pull review -r 810d78270512243b91f0e93a199907e9cbeaf406
(Assignee)

Comment 6

4 years ago
Comment on attachment 8586157 [details]
MozReview Request: bz://941085/ato

/r/6359 - Bug 941085: File uploads support in Marionette

Pull down this commit:

hg pull review -r 9c53900e6c7d8ba99f2d256dd2f054a346b011d5
Attachment #8586157 - Flags: review?(dburns)
Comment on attachment 8586157 [details]
MozReview Request: bz://941085/ato

https://reviewboard.mozilla.org/r/6357/#review5323

::: testing/marionette/driver.js
(Diff revision 2)
> +          let f;

variable name to `file`
Attachment #8586157 - Flags: review?(dburns)
(Assignee)

Comment 9

4 years ago
Comment on attachment 8586157 [details]
MozReview Request: bz://941085/ato

/r/6359 - Bug 941085: File uploads support in Marionette

Pull down this commit:

hg pull -r 73ab0d4b4ca088eca38ad8ff49286b97dff76b8c https://reviewboard-hg.mozilla.org/gecko/
Attachment #8586157 - Flags: review?(dburns)
(Assignee)

Comment 10

4 years ago
New try run, fixes sendKeysToElement for non-file input elements:  https://treeherder.mozilla.org/#/jobs?repo=try&revision=5583d4255b66
Try is not happy, will review after next try run
Attachment #8586157 - Flags: review?(dburns)
(Assignee)

Comment 12

4 years ago
Comment on attachment 8586157 [details]
MozReview Request: bz://941085/ato

/r/6359 - Bug 941085: File uploads support in Marionette

Pull down this commit:

hg pull -r 81ffce46bc24c3eb0485d42b4b27d5af262159cc https://reviewboard-hg.mozilla.org/gecko/
Attachment #8586157 - Flags: review?(dburns)
(Assignee)

Comment 14

4 years ago
Filed bug 1149998 since we seem unable to use HTMLElement#mozSetFileArray on CPOW-wrapped elements passed from a remote content process.
(Assignee)

Comment 15

4 years ago
Comment on attachment 8586157 [details]
MozReview Request: bz://941085/ato

/r/6359 - Bug 941085: File uploads support in Marionette

Pull down this commit:

hg pull -r 906d7b65c4bc4315fe0d93284e5ecdebb054130b https://reviewboard-hg.mozilla.org/gecko/
(Assignee)

Comment 16

4 years ago
new try run with test fixes for upload test: https://treeherder.mozilla.org/#/jobs?repo=try&revision=bf04b863f74f
Windows failure :(
(Assignee)

Comment 18

4 years ago
Disabled failing test on Windows due to http://bugs.python.org/issue14574 and filed bug 1150512 about moving to wptserve.

Pushed to inbound: https://hg.mozilla.org/integration/mozilla-inbound/rev/93166201fca0
(Assignee)

Updated

4 years ago
Attachment #8586157 - Flags: review?(dburns) → review+
(Assignee)

Comment 20

4 years ago
Fixed test failures and pushed to inbound again:  https://hg.mozilla.org/integration/mozilla-inbound/rev/f3a27b508519

The cause of the failures was that GaiaTestRunner relied on internal state set in BaseMarionetteTestRunner (self.httpd) and modified this.  This patch changed BaseMarionetteTestRunner.start_httpd to create_httpd which instead returned the httpd which the constructor assigned to self.httpd.

This was a problem for GaiaTestRunner because it is overriding start_httpd.
(Assignee)

Comment 22

4 years ago
Either e10s isn't being entirely truthful to us about its load events, or WebElement.click is doing something very wrong.  I added another explicit wait for the URL to change after the submit element is clicked.

I didn't see the problem rerunning the tests on e10s locally 40 times.

Pushed to inbound again: https://hg.mozilla.org/integration/mozilla-inbound/rev/3ea71f4c74e6
https://hg.mozilla.org/mozilla-central/rev/3ea71f4c74e6
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
(Assignee)

Comment 24

4 years ago
Attachment #8586157 - Attachment is obsolete: true
Attachment #8618061 - Flags: review+
You need to log in before you can comment on or make changes to this bug.