我一直在使用/学习量角器超过一个月了。量角器asnchronus执行问题
我知道,量角器文件说,它等待的角度调用来完成(http://www.protractortest.org/#/),这将确保所有 步骤同步执行等。
但我不找到它的方式。或者至少,我在脚本中找不到这种方式 许多时间量角器都在前面运行,例如,如果我点击一个链接,获取当前网址,然后验证网址。
大多数情况下,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
});
谢谢你的很好的解释。 – sathya
另外,有没有一种首选的方法来确保所有测试行(IT块)都是连续执行的?例如,console.log始终首先执行,而不是按它所在的顺序执行。 – sathya
实际上webdriverjs/protractor绑定中没有500 ms的轮询间隔.http://stackoverflow.com/a/34377095/771848。谢谢。 – alecxe