let name = 'test';
await page.evaluate(({name}) => {
console.log(name);
console.log(age);
console.log(location);
},{name});
傳遞 function
await page.exposeFunction("myFunc", myFunc);
Puppeteer-firefox
WebDriver.io
selenium-webdriver
nightmare
(使用electron當作介面)
異步需要參考如下:
var Nightmare = require('nightmare'),
nightmare = Nightmare({
show: true
});
nightmare
//load a url
.goto('http://localhost:5081')
//simulate typing into an element identified by a CSS selector
//here, Nightmare is typing into the search bar
.type('#username', 'daniel06')
.type('#password', 'qwe123')
.click('#loginBTN')
.wait(1000)
.click('#agree_btn')
function runplay(nightmare, gametype){
nightmare
.wait(1000)
.click(gametype)
.wait(1500)
.click('#auto_select')
.wait(1000)
.click('#bet_btn')
.wait(1000)
.click('#ok_btn')
.wait(1500)
.click('#other_btn')
}
runplay(nightmare, '#UUFFC');
runplay(nightmare, '#UUSSC');
runplay(nightmare, '#UU11X5');
runplay(nightmare, '#TCP3P5');
runplay(nightmare, '#JSK3');
nightmare
//end the Nightmare instance along with the Electron instance it wraps
//run the queue of commands specified
.run(function(error, result) {
if (error) {
console.error(error);
} else {
console.log(result);
}
});