Move uploadFiles onto ElementHandle (#348)

This patch:
- removes the `page.uploadFile` method
- adds `elementHandle.uploadFile` method.

Motivation: `elementHandle.uploadFile` is rarely used, so it doesn't worth it
to keep it on page.
This commit is contained in:
JoelEinbinder
2017-08-17 14:53:37 -07:00
committed by Andrey Lushnikov
parent ad1b292b6d
commit 5f0afd5547
6 changed files with 25 additions and 49 deletions

View File

@@ -15,7 +15,6 @@
*/
const fs = require('fs');
const path = require('path');
const EventEmitter = require('events');
const helper = require('./helper');
const ElementHandle = require('./ElementHandle');
@@ -325,21 +324,6 @@ class Frame {
return new WaitTask(this, predicateCode, polling, timeout).promise;
}
/**
* @param {string} selector
* @param {!Array<string>} filePaths
* @return {!Promise}
*/
async uploadFile(selector, ...filePaths) {
let expression = helper.evaluationString(selector => document.querySelector(selector), selector);
const {result} = await this._client.send('Runtime.evaluate', { expression });
if (!result)
return;
const objectId = result.objectId;
filePaths = filePaths.map(filePath => path.resolve(filePath));
return this._client.send('DOM.setFileInputFiles', { objectId, files: filePaths });
}
/**
* @return {!Promise<string>}
*/