- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在从 href
属性解析出一个 url,但是当我这样做时
casper.thenOpen(url, function() {
this.echo(this.getCurrentUrl());
});
显示空白。
我尝试访问的网页上的链接在新选项卡中打开,使用 casper 测试新选项卡比导航到同一选项卡上的新链接稍微复杂一些(我认为是这样)这就是为什么我在变量中获取链接然后尝试打开它。
我在这里遗漏了什么吗?
代码片段:
var href = '';
casper.then(function() {
this.test.assertExists(x('//a[contains(@href, "SUBSTRING OF URL")]'), 'the element exists');
href = casper.getElementAttribute(x('//a[contains(@href, "SUBSTRING OF URL")]'), 'href');
});
casper.thenOpen(href, function() {
this.echo(getCurrentUrl());
});
因此,当我 echo href
时,它的值与我要导航到的 url 相同。但是 getCurrentUrl
显示 about:blank
。此外,URL 在不到一秒的时间内打开,但当我尝试 casper.waitForUrl()
时,它在 5000 毫秒后超时。
最佳答案
Casper 的工作原理是将所有请求推送到堆栈上,然后运行它们。所以当你这样称呼时:
casper.thenOpen(href, function() {
this.echo(getCurrentUrl());
});
href
尚未有机会被定义。我相信以下重构是修复它的一种方法:
casper.then(function() {
casper.open(href,function(){
this.echo("Did it work this time?");
});
});
关于javascript - 当应从先前设置的变量打开下一页时,下一页未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27023916/
我在一个 Azure 移动服务自定义 API 项目中,按照此处所述实现了自定义身份验证: https://azure.microsoft.com/en-us/documentation/article
由于 Artifact 的错误,我的 gradle 构建失败: FAILURE: Build failed with an exception. * What went wrong: Could no
from matplotlib import pyplot as plt import numpy as np import pandas as pd from matplotlib.ticker i
如您所知,您可以将多种媒体类型添加到 HTTP Accept header 。当谈到“服务器应该返回什么类型?”这个问题时大多数解释和规范似乎只解释了根据媒体类型的特性、质量和级别选择“首选”媒体类型
我是一名优秀的程序员,十分优秀!