2

三个月前我写了测试用例,当时它们工作得很好,现在我想在另一个系统中运行这些测试用例,所以我做了基本的设置。当我现在尝试运行量角器测试用例时,它们因“无法启动 WebDriver 会话”而失败。我尝试了很多解决方案,但它们对我不起作用。在这里,我附上了我的 protractor.conf.js 文件和错误详细信息。

量角器.conf.js

'use strict';

exports.config = {

seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

baseUrl: 'http://localhost:' + (process.env.PORT || '3036'),

chromeOnly: true,

// To get the maximimum test screen size
onPrepare: function() {
    browser.driver.manage().window().maximize();
},

// list of files / patterns to load in the browser
specs: [
'e2e/attributeSection/search_spec.js', 'e2e/attributeSection/create_spec.js', 
'e2e/attributeSection/edit_spec.js', 'e2e/attribute/search_spec.js', 
'e2e/attribute/create_spec.js', 'e2e/attribute/edit_spec.js',
'e2e/classification/search_spec.js', 'e2e/classification/create_spec.js', 
'e2e/classification/edit_spec.js', 'e2e/classificationGroup/create_spec.js', 
'e2e/classificationGroup/edit_spec.js'
],

exclude: [],

capabilities: {
'browserName': 'chrome',
'chromeOptions': {
    binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
    args: [],
    extensions: [],
}
},

framework: 'jasmine',
jasmineNodeOpts: {
  defaultTimeoutInterval: 60000
}
};

控制台错误

Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.

C:\Users\Cronj-  4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145
  callback(new Error(message));
           ^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest.<anonymous> (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:145:16)
at ClientRequest.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1552:9)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickCallback (node.js:442:13)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:155:22)
at Function.webdriver.WebDriver.createSession (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:129:30)
at [object Object].Builder.build (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\builder.js:416:22)
at [object Object].DriverProvider.getNewDriver (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.js:38:7)
at [object Object].Runner.createBrowser (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:180:37)
at C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\lib\runner.js:257:21
at _fulfilled (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:797:54)
at self.promiseDispatch.done (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:826:30)
at Promise.promise.promiseDispatch (C:\Users\Cronj-4\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:759:13)

谁能帮帮我?提前致谢

4

2 回答 2

5

我相信“chromeOnly”选项在 v2.0.0 中已被弃用。

chromeOnly: true,

这曾经意味着在没有 selenium 服务器的情况下使用“直接”模式。但由于 firefox 和 chrome 都支持直接模式,因此将该属性重命名为“directConnect”。所以将该行更改为:

directConnect: true,

在这种模式下,您不需要 selenium 服务器,因此您可以删除seleniumAddress只会让人们感到困惑的属性。

https://github.com/angular/protractor/pull/1933/files

于 2015-03-27T18:43:46.333 回答
2

我在一个命令提示符中运行 webdriver-manager start 并在另一个命令提示符中运行量角器,然后只有测试用例开始运行

于 2015-04-01T10:16:00.750 回答