我是量角器的新手,我正在尝试实施e2e测试.我不知道这是否是正确的方法,但是...我要测试的页面不是基于完整的角度页面,所以......我遇到了一些麻烦.
根据我的第一个规范,我有:
describe('should open contact page', function() {
var ptor = protractor.getInstance();
beforeEach(function(){
var Login = require('./util/Login');
new Login(ptor);
});
Run Code Online (Sandbox Code Playgroud)
我已创建此Login类,但登录后我想打开联系页面,但量角器会在页面完全加载之前立即尝试查找元素.
我试过用:
browser.driver.wait(function() {
expect(browser.findElement(by.xpath("//a[@href='#/contacts']")).isDisplayed());
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
Run Code Online (Sandbox Code Playgroud)
但它不起作用......它总是试图在页面加载之前找到元素.我也试过这个:
browser.driver.wait(function() {
expect(ptor.isElementPresent(by.xpath("//a[@href='#/contacts']")));
ptor.findElement(by.xpath("//a[@href='#/contacts']")).click();
});
Run Code Online (Sandbox Code Playgroud)
我能够使用browser.sleep();
但我不认为这是一个不错的选择.任何的想法?在我的登录课上,我有:
ptor.ignoreSynchronization = true;
Run Code Online (Sandbox Code Playgroud)
@href='#/contacts
在量角器尝试点击它之前,我该如何等待?
javascript automated-tests angularjs selenium-webdriver protractor