2013-04-08 59 views

回答

6

在这里你去:

var yourClientJSFunction = function (param1, param2) { 
    // the JS code you want to run in the browser 
} 

driver.executeAsyncScript(yourClientJSFunction, param1, param2).then(function (res) { 
    // deal with the response 
}); 
1

如果您在节点中使用camme/webdriverjs,您可以使用下面的代码片段:

client 
    .execute(function() { 
    return $('ul li').length; 
    }, [], function (err, result) { 
    console.log(result.value); // 4 
    }) 
    .call(done); 

在这里,我们使用得到的列表项的数目jQuery的。我们通过访问result.value来处理回调函数中的结果。

它也可作为一个要点在这里:https://gist.github.com/ragulka/10458018

相关问题