config.js超时失败:等待后30009ms
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'Login.js',
'FeatureList.js',
'NewApplicationRegistration.js',
'ApplicationRegistrationManagement.js',
'RegistrationStatus.js',
],
baseUrl: 'http://localhost:3000',
multiCapabilities: [{
'browserName': 'chrome'
},
// {
// 'browserName': 'firefox'
// },
// {
// 'browserName': 'internet explorer'
// }
],
jasmineNodeOpts: {
onComplete: null,
isVerbose: false,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 3000000
},
allScriptsTimeout: 11000,
rootElement: 'html',
onPrepare: function() {
browser.ignoreSynchronization = true;
browser.driver.manage().window();
},
};
1规范文件
'use strict'
describe('Application Registration Page', function() {
beforeEach(function() {
browser.waitForAngular();
browser.get('/register');
});
// Login
it('Test for Login', function() {
expect(element(by.xpath('/html/body/admin-app-root/layout/div[1]/div/ng-component/div/form/div/table/tbody/tr[1]/th/label')));
var EC = protractor.ExpectedConditions;
var username = element(by.id('login-username'));
browser.wait(EC.visibilityOf(username), 30000);
username.sendKeys('sss');
expect(element(by.xpath('/html/body/admin-app-root/layout/div[1]/div/ng-component/div/form/div/table/tbody/tr[2]/th/label')));
var EC = protractor.ExpectedConditions;
var password = element(by.id('login-password'));
browser.wait(EC.visibilityOf(password), 30000);
password.sendKeys('sss');
browser.driver.sleep(1000);
element(by.xpath('/html/body/admin-app-root/layout/div[1]/div/ng-component/div/form/div/table/tbody/tr[3]/td/button')).click().then(function (username, password) {
if (username, password) {
browser.navigateTo('http://localhost:3000/register/core/feature-list');
} else {
expect(browser.isElementPresent(element(by.xpath('/html/body/admin-app-root/layout/div[1]/div/ng-component/div/form/div/table/tbody/tr[1]/td/b'))));
}
});
});
});
第二规格
'use strict'
describe('Welcome to feature list', function() {
beforeEach(function() {
browser.waitForAngular();
browser.get('/register/core/feature-list');
});
describe('Header', function() {
// Application Registration text
it('Test for Application Registration text', function() {
var EC = protractor.ExpectedConditions;
var ar = element(by.xpath('/html/body/admin-app-root/layout/div[1]/c-header/nav/div/div[1]/a[2]'));
browser.wait(EC.presenceOf(ar), 2000000);
expect(ar.getAttribute('value')).toEqual('Application Registration');
});
it('Test for user name', function() {
var EC = protractor.ExpectedConditions;
var username = element(by.xpath('//*[@id="cox-navbar"]/ul/li[1]/a'));
browser.wait(EC.visibilityOf(username), 2000);
expect(username.isPresent()).toBe(true);
});
});
1规范的脚本运行良好,但,同时运行第2规格我得到一个错误说:
等待超时后2000000ms
即使脚本超时是非常大的它越来越错误。在给定的时间内,它无法从浏览器中找到元素。
帮我找到解决方案。
您是否尝试过使用此元素的其他选择器?使用这种xpath有点不好,也许尝试使用css类,名称或id? – Hikaryu
@Hikaryu,亚我已经尝试了所有的期望,但同样的错误,我越来越。但有一件事我看到,虽然运行2nd规范它只显示第一个规格页面,但我不确定是否加载了第二个规格的browser.get页面。 – amit