- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不太了解 nightmarejs,所以它可能真的很简单。
我的问题是,为什么应用卡在 Facebook 网址上而没有转到 Google?
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('https://facebook.com')
.evaluate(function () {
return document.title;
}
)
.then(function(result){
console.log(result)
nightmare.goto('https://google.com')
})
最佳答案
以下行返回一个 promise ,您首先将 promise 解析为数据。只需在 Nightmare promise 链中添加一个 then()
。
nightmare
.goto('https://google.com')
.then(function(){
console.log("I'm done")
})
这是带有更好链的完整代码。
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('https://facebook.com')
.evaluate(function () {
return document.title;
}
)
.then(function(result){
console.log(result)
return nightmare.goto('https://google.com')
})
.then(function(){
console.log("I am on google")
})
关于javascript - NightmareJs goto 评估后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46586894/
我试图处理测试工具,例如 Nightmare ,幻影等。而且似乎被一些基本的DOM操作所困扰。我在这里使用jquery以便以后使用$()。parent()方法。香港专业教育学院已经尝试了所有可能的选择
我正在编写一个小 Nightmare 脚本,该脚本在Web表单中键入名称并读取打印在表中的结果。我已经输入了输入内容,并得到如下表结果: { jQuery110205953448106032428:
我尝试使用Nightmare依次访问页面上的不同链接,但是第二个 promise 似乎被拒绝(即使不应该这样做,也可以使用“.evaluate”而不是“.exists”)。 这是我的功能: async
是否可以从 HTML 字符串创建页面,就像使用 jsdom 一样,如下所示: global.document = jsdom.jsdom(''); 而不是使用 goto方法。 最佳答案 如果您愿意写入
考虑以下 NightmareJS 脚本... var Nightmare = require('nightmare'); var yandex = new Nightmare() .viewp
我正在尝试从 Drupal 站点的两个网页中提取标题标签文本。我想使用 Nightmarejs。 到目前为止,这是我的代码: // get the text from inside the Drup
我目前正在制作一个 electron 应用程序,我在项目中包含了 Nightmare。 var nightmare = Nightmare({ show: true }) nightmare
感谢@pipo_dev,我能够解决在 NightmareJS 中进行多次评估时遇到的问题,我想知道的一件事是我是否可以为同一测试提供多个报告,以以下为例: describe('test google
我正在尝试使用 Nightmarejs 构建一个脚本,该脚本能够一遍又一遍地单击一个按钮,就像评论部分底部的 youtube 按钮一样,每次按下它时都会加载较旧的评论(例如:youtube .com/
以下代码适用于 NightmareJS 和 NodeJS。但是,我不想只 console.log 我的 JSON 结果,而是想将我的 JSON 结果保存到本地文件。 我知道 Nightmare 中的
当我运行一个评估时,NightmareJS 工作得很好,但是当我与页面交互时,我需要在事情通过时做更多的评估。但是,使用文档我尝试了一个简单的链接评估示例,但出现错误: describe('test
我有一个应用程序,该应用程序使用“纽约时报”食谱网址,并将食材 list 转换为购物待办事项 list 。 由于《纽约时报》使用React,因此无法通过标准抓取方式获得任何数据-index.html大
我试图让 Nightmare js做一个.evaluate,然后在它返回一个值之后执行一个.then(function(varFromEvaluate){}),但是.then函数在评估完成之前就执行了
今晚我正在尝试 Nightmarejs,我想在运行时有一个需要用户输入的步骤。有没有办法让 nightjs 允许这样的事情?我修改了库附带的 type() 方法,并且能够停止执行以输入一些文本。脚本甚
我正在使用nightmarejs我有一个不知道如何解决的问题。 我使用指令goto(URL),然后使用指令evaluate(),以便在网页上执行某些操作。DOM 在 2-3 秒后准备就绪,但我相信指令
我对 NodeJs 和 NightmareJs 非常陌生。我需要使用 nightmare-inline-download 从同一页面下载多个文件插入。到目前为止,我下面的代码可以下载第一个文件。但我不
我不太了解 nightmarejs,所以它可能真的很简单。 我的问题是,为什么应用卡在 Facebook 网址上而没有转到 Google? var Nightmare = require('nigh
我使用 NightmareJS 进行 headless 测试。 有时,像这样的元素会出现在我正在浏览的网站的 DOM 中。 Error div 上没有ID。我需要一种方法来测试当前页面上是否存在带有
我是 JavaScript、node.js 和 NightmareJS 的新手。 我在下面编写了一个简单的脚本来从网页中提取一些文本,我想将它保存到一个文件中。 var nightmare = req
我正在尝试使用 Nightmarejs 制作简单的跟随脚本。它应该以下一种方式工作: 转到一些用户个人资料 点击按钮打开该用户的关注者列表 点击所有关注按钮,每次点击之间有延迟 点击加载更多 重复第
我是一名优秀的程序员,十分优秀!