我使用 Protractor 和 CucumberJS 设置了一些 e2e 测试,但是在使用 Chrome 时遇到了很多困难。测试在 Firefox 上顺利通过,但在 Chrome 中,它们在任何步骤中随机停止。有时它只是挂起加载和 url,有时它会突然停止发送密钥,有时它会挂起试图“单击”一个按钮。有人有什么主意吗?在 Firefox 上一切正常。我已经尝试了很多东西:ignoreSyncronization,waitForAngular 没有任何运气......这是我的步骤定义:
module.exports = function() {
var login = new Login();
this.Given('I go on "$url"', function(url, callback) {
browser.get(url);
callback();
});
this.Given('I logged in with user "$userName" and password "$password"', function(userName, password, callback) {
browser.element(by.id('userName')).sendKeys(userName).then(function() {
browser.element(by.id('password')).sendKeys(password).then(function() {
browser.element(by.id('btnLogin')).click().then(callback);
});
});
});
this.Then('The user is redirected to the Dashboard page on "$dashboardUrl"', function(dashboardUrl, callback) {
this.expect(browser.getCurrentUrl()).to.eventually.equal(dashboardUrl).and.notify(callback);
});
this.Then('I log the user out', function(callback) {
login.getUserProfileMenuElement().click().then(function() {
login.getLogUserOutElement().click();
callback();
});
});
};
这里有两个不同的屏幕截图,第一次,停止加载 url,第二次,发送密钥:
https://dl.dropboxusercontent.com/u/1437542/run1.jpg https://dl.dropboxusercontent.com/u/1437542/run2.jpg