【发布时间】:2016-05-13 02:54:05
【问题描述】:
我已经使用/学习量角器一个多月了。
我知道量角器文档说,它等待角度调用完成 (http://www.protractortest.org/#/),它将确保所有 步骤同步执行等等。
但我不这么认为。或者至少,我在我的脚本中没有找到这种方式 很多时候量角器会提前运行,例如,如果我单击链接,获取当前 url,然后验证 url。
大多数情况下,URL 值将是陈旧的,即点击链接后它没有被执行。下面是我的页面对象和相应测试的代码示例。
请建议如何确保,所有测试步骤都按顺序执行。
Page Object
this.getSPageLink(){
return element(by.xpath("//a[@title='S']"));
};
this.getLPageLink(){
return element(by.xpath("//a[@title='L']"));
};
this.goToSPage = function() {
(this.getSPageLink()).click();
*//ERROR here, sometimes second click (below) doesn't wait for first
click to complete, and complains that link for 2 click (below) is
not found*
(this.getSLPageLink()).click();
return browser.currentURL();
*//ERROR HERE url line (e) is sometimes executed before*
}
Test Class
it('::test SL page', function() {
pageObject.goToSpage();
var currentURL=browser.getCurrentURL();
expect(currentURL).toContain("SLink");
*//ERROR HERE value in this variable "currentURL" is most of the
times Stale*
});
it('::test SL2 page', function() {
pageObject.goToLpage();
var currentURL=browser.getCurrentURL();
expect(currentURL).toContain("Link");
console.log("this line is always executed first"));
//ERROR here , this print line is always executed first
});
【问题讨论】:
标签: javascript angularjs protractor