在我的应用程序中,我遇到了 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
});
});
输出:当单击该元素时,图像没有包含我想要的内容。
请帮我解决这个问题。
谢谢, 纳拉赛亚 p
最佳答案
尝试在此处指定宽度
和高度
:
width: viewport.viewport.width,
height: viewport.viewport.height
而不是:
width: 0,
height: 0
关于javascript - 即使在casperjs中assertExist为true也找不到元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23078353/