【发布时间】:2017-12-22 13:51:51
【问题描述】:
在使用 Protractor 对 Angular 应用程序运行端到端回归测试时,我无法克服这些失败。当我对 Chrome 和 Firefox 运行相同的测试时,两者总是通过。但是,当针对 Safari 或 Safari Technology Preview 运行时……我遇到了同样的堆栈故障。这是一个 Angular 应用程序,所以我不能只是“关闭”或“禁用”等待 Angular。
节点 8.0.0、量角器 5.1.1、npm 5.0.4、Selenium 3.4.0.jar、macOS Sierra 10.12.5
Safari - 10.1.1 (12603.2.4)
Safari 技术预览版 - 第 35 版(Safari 11.0、WebKit 12604.1.29)
*允许启用远程自动化
Safari 堆栈:
NoSuchWindowError: A request to use a window could not be satisfied because the window could not be found.
Failed: Error while running testForAngular: A script did not complete before its timeout expired.
Safari 技术预览栈:
Failed: Error while running testForAngular: A script did not complete before its timeout expired.
Command duration or timeout: 20.01 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.5', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, databaseEnabled=true, handlesAlerts=true, version=12604.1.29, cleanSession=true, platform=MAC, nativeEvents=true,
locationContextEnabled=false, webStorageEnabled=true, browserName=safari, javascriptEnabled=true, platformName=macOS, cssSelectorsEnabled=true}]
量角器配置文件
"use strict";
exports.config = {
framework: 'jasmine2',
capabilities: {
browserName: 'safari',
'safari.options': {technologyPreview: true },
}
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 500000,
includeStackTrace : true
},
onPrepare: functionI() {
browser.driver.manage().window().setSize(1600, 1200);
},
getPageTimeout: 500000,
allScriptsTimeout: 20000,
seleniumAddress: 'http://localhost:4444/wd/hub',
specs:['10ALMWspec.js', '11ALMWspec.js']
};
JavaScript 规范文件
"use strict";
var loginPage = require('../pages/mobileWebLoginPage.js');
var homePage = require('../pages/mobileWebHomePage.js');
describe('10ALMWspec', function() {
it('Should validate login and logout functionality', function() {
loginPage.getDEV();
loginPage.mobileWebValidLogin();
expect(homePage.contactName.isDisplayed()).toBe(true);
expect(homePage.clickToSelectTeamAnchor.isDisplayed()).toBe(true);
expect(homePage.logOutBtn.isDisplayed()).toBe(true);
homePage.logOutBtn.click();
});
});
JavaScript 页面文件
'use strict';
var MobileWebLoginPage = function()
{
this.testUserLoginInputBox = element(by.css('[data-qa-id="loginALMWUserIdInput"]'));
this.testUserPasswordInputBox = element(by.css('[data-qa-id="passwordALMWInput"]'));
this.loginBtn = element(by.css('[data-qa-id="loginALMWBtn"]'));
this.popUpMessage = element(by.css('[class="popup-body"] span'));
this.popUpMessageOkBtn = element(by.css('[class="popup-buttons"] button'));
this.getDEV = function()
{
browser.get('https://foo/mobile-app/', 500000);
};
this.getUAT = function()
{
browser.get('https://bar/mobile-app/', 500000);
};
this.mobileWebValidLogin = function()
{
this.testUserLoginInputBox.sendKeys('testuser');
this.testUserPasswordInputBox.sendKeys('testpassword');
this.loginBtn.click();
};
this.mobileWebInvalidLogin = function()
{
this.testUserLoginInputBox.sendKeys('testuser2');
this.testUserPasswordInputBox.sendKeys('test2password');
this.loginBtn.click();
};
};
module.exports = new MobileWebLoginPage();
【问题讨论】:
标签: javascript angular selenium-webdriver safari protractor