puppeteer
Advanced tools
Comparing version 1.0.0-next.1514951743425 to 1.0.0-next.1515022965203
@@ -198,17 +198,26 @@ /** | ||
* @param {string} expression | ||
* @return {!Promise<?ElementHandle>} | ||
* @return {!Promise<!Array<!ElementHandle>>} | ||
*/ | ||
async xpath(expression) { | ||
const handle = await this.executionContext().evaluateHandle( | ||
async $x(expression) { | ||
const arrayHandle = await this.executionContext().evaluateHandle( | ||
(element, expression) => { | ||
const document = element.ownerDocument || element; | ||
return document.evaluate(expression, element, null, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue; | ||
const iterator = document.evaluate(expression, element, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE); | ||
const array = []; | ||
let item; | ||
while ((item = iterator.iterateNext())) | ||
array.push(item); | ||
return array; | ||
}, | ||
this, expression | ||
); | ||
const element = handle.asElement(); | ||
if (element) | ||
return element; | ||
await handle.dispose(); | ||
return null; | ||
const properties = await arrayHandle.getProperties(); | ||
await arrayHandle.dispose(); | ||
const result = []; | ||
for (const property of properties.values()) { | ||
const elementHandle = property.asElement(); | ||
if (elementHandle) | ||
result.push(elementHandle); | ||
} | ||
return result; | ||
} | ||
@@ -215,0 +224,0 @@ } |
@@ -310,7 +310,7 @@ /** | ||
* @param {string} expression | ||
* @return {!Promise<?ElementHandle>} | ||
* @return {!Promise<!Array<!ElementHandle>>} | ||
*/ | ||
async xpath(expression) { | ||
async $x(expression) { | ||
const document = await this._document(); | ||
const value = await document.xpath(expression); | ||
const value = await document.$x(expression); | ||
return value; | ||
@@ -317,0 +317,0 @@ } |
@@ -242,6 +242,6 @@ /** | ||
* @param {string} expression | ||
* @return {!Promise<?Puppeteer.ElementHandle>} | ||
* @return {!Promise<!Array<!Puppeteer.ElementHandle>>} | ||
*/ | ||
async xpath(expression) { | ||
return this.mainFrame().xpath(expression); | ||
async $x(expression) { | ||
return this.mainFrame().$x(expression); | ||
} | ||
@@ -248,0 +248,0 @@ |
{ | ||
"name": "puppeteer", | ||
"version": "1.0.0-next.1514951743425", | ||
"version": "1.0.0-next.1515022965203", | ||
"description": "A high-level API to control headless Chrome over the DevTools Protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
246473
6206