selectorExecute
Works just like execute, only you can use selectors to pass html elements to
the function you wish to execute in the browser.
The function fn will receive every resolved selector as an array of html elements,
even if there is only one result, or no result.
These arrays are the first arguments the function fn receives.
If you pass an array of selectors, the resulting html element arrays are returned in the same order.
All arguments you append after function fn are added as the arguments after the html arrays.
You can use any JSON value or a function as such an argument.
Usage
1
| client.selectorExecute(selectors,script[,argument1,...,argumentN]).then(callback);
|
Parameters
Param |
Type |
Details |
selectors |
String/Array. |
single selector or array of selectors |
script |
Function |
function to get executed in the browser |
argument1,…,argumentN |
…* |
arguments added to fn. Can be any JSON value or function |
Example
selectorExecute.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| client.selectorExecute("//div", function(divs, message) { return divs.length + message; }, " divs on the page").then(function(res) { console.log(res); });
client.selectorExecute(["//div", "=Read Post"], function(divs, links) { var message = 'There are ';
message += divs.length + ' divs on the page'; message += ' and '; message += links.length + ' links with an link text "' + links[0].text + '"';
return message; }).then(function(res) { console.log(res); });
|
Uses