我有一个每10分钟运行一次的量角器安装。我将Firefox与directConnect一起使用,因为我需要设置一个用户代理,而且我不能使用chrome,因为如果同时运行两个量角器实例,它就会失败。
每天至少发生一次超时:
Using FirefoxDriver directly...
[launcher] Running 1 instances of WebDriver
/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:89
Error('Timed out waiting for the WebDriver server at ' + url));
^
Error: Timed out waiting for the WebDriver server at http://127.0.0.1:50162/hub
at Error (native)
at onResponse (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:89:11)
at /u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/http/util.js:44:21
at /u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.js:140:5
at ClientRequest.<anonymous> (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172:7)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at new Driver (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/selenium-webdriver/firefox/index.js:277:36)
at [object Object].DirectDriverProvider.getNewDriver (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/lib/driverProviders/direct.js:75:16)
at [object Object].Runner.createBrowser (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/lib/runner.js:182:37)
at /u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/q/q.js:759:13)
at /u01/node-v4.2.2-linux-x64/lib/node_modules/protractor/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
版本: 量角器2.5.1(Selenium WebDriver 2.47.0) 节点v4.2.2 Firefox 38.2.1
protractor.config.js
var firefox = require('selenium-webdriver/firefox');
var firefoxProfile = new firefox.Profile();
firefoxProfile.setPreference("general.useragent.override", 'monitoring7758932056');
firefoxProfile.setPreference('startup.homepage_welcome_url.additional', 'about:blank');
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'firefox',
'firefox_profile': firefoxProfile
},
suites: {
login: 'login.spec.js',
},
baseUrl: 'http://192.168.1.100:8080/application',
};
login.spec.js
describe( 'login', function () {
var loginPage;
beforeEach( function () {
loginPage = require( './LoginPage.js' );
} );
it( 'should let a user to login', function () {
loginPage.get();
loginPage.loginAsTestUser();
expect( login.isCurrentPage() ).toBe( false );
} );
} );
LoginPage.js
function LoginPage () {
function get() {
browser.get( '' );
}
function loginAsTestUser () {
element( by.model( 'username' ) ).sendKeys( 'user' );
element( by.model( 'password' ) ).sendKeys( 'password' );
return element( by.xpath( '//button[@type=\'submit\']' ) ).click();
}
function isCurrentPage() {
return element( by.model( 'password' ) ).isPresent();
}
}
module.exports = new LoginPage();
如何避免这些超时?
答案 0 :(得分:0)
你错误地设置了firefox个人资料,并不是那么简单。有一个setFirefoxProfile
方法,展示了如何通过制作自定义的firefox配置文件来设置firefox首选项。