mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Implement page.waitForFunction method
The page.waitForFunction method allows to wait for a general predicate. The predicate will be continiously polled for in page, until it either returns true or the timeout happens. The polling parameter could be one of the following: - 'raf' - to poll on every animation frame - 'mutation' - to poll on every dom mutation - <number> - to poll every X milliseconds References #91
This commit is contained in:
14
lib/Page.js
14
lib/Page.js
@@ -571,6 +571,16 @@ class Page extends EventEmitter {
|
||||
return this.mainFrame().waitForSelector(selector, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function()} pageFunction
|
||||
* @param {!Object=} options
|
||||
* @param {!Array<*>} args
|
||||
* @return {!Promise}
|
||||
*/
|
||||
waitForFunction(pageFunction, options = {}, ...args) {
|
||||
return this.mainFrame().waitForFunction(pageFunction, options, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} selector
|
||||
* @param {!Array<string>} filePaths
|
||||
@@ -637,10 +647,10 @@ function convertPrintParameterToInches(parameter) {
|
||||
if (typeof parameter === 'undefined')
|
||||
return undefined;
|
||||
let pixels;
|
||||
if (typeof parameter === 'number') {
|
||||
if (helper.isNumber(parameter)) {
|
||||
// Treat numbers as pixel values to be aligned with phantom's paperSize.
|
||||
pixels = /** @type {number} */ (parameter);
|
||||
} else if (typeof parameter === 'string') {
|
||||
} else if (helper.isString(parameter)) {
|
||||
let text = parameter;
|
||||
let unit = text.substring(text.length - 2).toLowerCase();
|
||||
let valueText = '';
|
||||
|
||||
Reference in New Issue
Block a user