2013-04-08 61 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

相關問題