我目前正在制作一个电子应用程序,我已经在项目中包括了梦魇。
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit').then(nightmare.show())这就是我希望看到的打开浏览器窗口的代码,请访问yahoo.com。
为什么当我表演的时候,它仍然是无头的:真的?
航站楼:
$ DEBUG=nightmare* electron .
nightmare queuing process start +0ms
nightmare queueing action "goto" for http://yahoo.com +3ms
nightmare queueing action "type" +2ms
nightmare queueing action "click" +0ms
nightmare running +0ms我还修改了代码,其中包括整个代码片段:
ipc.on('launchBrowser', function(event, data){
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit').then(() => { });
});因为我没有显式地使用node.js,而是电子,所以它不像预期的那样工作吗?
发布于 2017-09-28 11:23:59
我认为如果没有接收到它的值,就不能调用一个函数()在“那么”内。
可能是抛出了某种错误,即使您不需要nightmare.show(),因为在创建实例时设置了属性
对于这样的事情,要么改变:
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit').then(nightmare.show)或者这个:
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit').then(() => { nightmare.show(); });或者完全删除nightmare.show()
var nightmare = Nightmare({ show: true })
nightmare
.goto('http://yahoo.com')
.type('input[title="Search"]', 'github nightmare')
.click('.searchsubmit').then(() => { //Something cool });https://stackoverflow.com/questions/46467492
复制相似问题