即使assertExist在casperjs中为true,也找不到元素
Element is not found even assertExist is true in casperjs
在我的应用程序中,我在casperjs
中遇到一个问题。
我正在做的步骤如下。
1) 首先我做断言,不管元素是否存在。
casper.then(function() {
this.test.assertExists(
{ type: 'xpath', path: '//header[@id="masthead"]/section[3]/div/div/nav/ul[1]/li[2]/a[1]' },
'the element exists'
);
});
输出:通过
2) 点击该元素
casper.then(function() {
this.click(x('//header[@id="masthead"]/section[3]/div/div/nav/ul[1]/li[2]/a[1]'));
this.echo('clicking product and services enter code here page');
});
输出:点击产品和服务页面
3) 捕捉图像。
casper.then(function() {
this.echo("Capturing image website");
this.capture('images/po/productServices.png', {
top: 0,
left: 0,
width: 0,
height: 0
});
});
输出:当点击该元素时,图像并不是我想要的。
请帮我解决这个问题。
谢谢,Narasaiah p
尝试在此处指定width
和height
:
width: viewport.viewport.width,
height: viewport.viewport.height
而不是:
width: 0,
height: 0
尝试使用等待指令-waitForSelector、waitForUrl、waitForText…-在3)点击后:
示例:
casper.waitForSelector('the selector to wait before taking the capture', function() {
this.capture('images/po/productServices.png');
});
相关文章:
- [Vue warn]:找不到元素
- 在页面中找不到元素的正确位置.函数未考虑填充
- JQuery找不到元素
- 在Selenium Web驱动程序2.0中找不到元素
- 没有这样的元素:找不到元素:正在验证web元素是否丢失
- jQuery没有'找不到元素或其属性
- 量角器 3.1.1 + 角度 2:找不到元素的可测试性
- jQuery .each() 在 wooCommerce header cart list 中找不到元素
- jQuery 找不到元素
- getElementsByClassName() 在 Firefox 25 中找不到元素
- 在网页上找不到元素,因为它加载了基于javascript的错误并在几秒钟后隐藏(注册表单)
- 如果jQuery不抱怨/抛出错误'在选择器中找不到元素
- jQuery在ngView加载的元素[AngularJS]上找不到元素
- Rails/Javascript选择器赢得'找不到元素
- 可以'在window.deocument.forms[0]中找不到元素
- CasperJS找不到元素,即使我可以在开发人员工具中按CTRL-F它
- PHP或Javascript:找不到元素错误
- onRenderd在Meteor中找不到元素
- 为什么它找不到元素的内部 HTML
- ' getElementById '在' '标签中找不到元素