Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firefox): support elementHandle.uploadFile #4058

Merged
merged 1 commit into from Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions experimental/puppeteer-firefox/lib/JSHandle.js
@@ -1,4 +1,5 @@
const {assert, debugError} = require('./helper');
const path = require('path');

class JSHandle {

Expand Down Expand Up @@ -327,6 +328,18 @@ class ElementHandle extends JSHandle {
await this._frame._page.mouse.click(x, y, options);
}

/**
* @param {!Array<string>} filePaths
*/
async uploadFile(...filePaths) {
const files = filePaths.map(filePath => path.resolve(filePath));
await this._session.send('Page.setFileInputFiles', {
frameId: this._frameId,
objectId: this._objectId,
files,
});
}

async hover() {
await this._scrollIntoViewIfNeeded();
const {x, y} = await this._clickablePoint();
Expand Down
4 changes: 4 additions & 0 deletions experimental/puppeteer-firefox/misc/puppeteer.cfg
Expand Up @@ -26,6 +26,10 @@ pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
// (bug 1176798, bug 1177018, bug 1210465)
pref("apz.content_response_timeout", 60000);

// Allow creating files in content process - required for
// |Page.setFileInputFiles| protocol method.
pref("dom.file.createInChild", true);

// Indicate that the download panel has been shown once so that
// whichever download test runs first doesn't show the popup
// inconsistently.
Expand Down
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/package.json
Expand Up @@ -9,7 +9,7 @@
"node": ">=8.9.4"
},
"puppeteer": {
"firefox_revision": "86e93329fd528bd28ff1493f117f126b6f010eac"
"firefox_revision": "e0433ecec0642eca12cba778b0587ab2ae06e833"
},
"scripts": {
"install": "node install.js",
Expand Down
2 changes: 1 addition & 1 deletion test/input.spec.js
Expand Up @@ -21,7 +21,7 @@ module.exports.addTests = function({testRunner, expect}) {
const {it, fit, xit, it_fails_ffox} = testRunner;
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
describe('input', function() {
it_fails_ffox('should upload the file', async({page, server}) => {
it('should upload the file', async({page, server}) => {
await page.goto(server.PREFIX + '/input/fileupload.html');
const filePath = path.relative(process.cwd(), __dirname + '/assets/file-to-upload.txt');
const input = await page.$('input');
Expand Down