无法启动ChromeDriver-Protractor

时间:2015-03-30 03:21:36

标签: angularjs selenium selenium-webdriver webdriver protractor

我见过几个其他线程处理类似的问题,但不一样。我使用直接连接到浏览器,ChromeDriver偶尔无法启动以下错误。看起来我可以在配置文件中设置一些浏览器超时,但是无法弄明白。 conf.js看起来像

'use strict';

exports.config = {
    /* seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
     ** enables to connect to the browsers directly.
     ** http://stackoverflow.com/questions/27889488/cannot-run-protractor-on-internet-explorer-11
     */

    directConnect: true,
    specs: ['giftengHomePageTests.js'],

    multiCapabilities: [{
        'browserName': 'chrome'
    }, {
        'browserName': 'firefox'
    },

    /**
     * {
     * 'browserName': 'internet explorer'
     * }
     * */

    ],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        isVerbose: true
    },

    onPrepare: function () {
        browser.driver.manage().window().maximize();
    }
}
  

[chrome#1]直接使用ChromeDriver ......

     

[chrome#1]错误 - 无法启动WebDriver会话。

     

[chrome#1]错误:听EACCES

错误更新

我已多次运行这些相同的测试,现在在Firefox驱动程序上失败了。这是非常不正常的

  

" D:\ Program Files(x86)\ JetBrains \ WebStorm 9.0.3 \ bin \ runnerw.exe" " D:\ Program Files \ nodejs \ node.exe" d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ lib \ cli.js specs \ smoke \ conf.js   [launcher]运行2个WebDriver实例

     
     

[firefox#2] PID:5748   [firefox#2]规格:e:\ working \ protractor-e2e \ specs \ smoke \ giftengHomePageTests.js   [firefox#2]   [firefox#2]直接使用FirefoxDriver ......   [firefox#2]错误 - 无法启动WebDriver会话。   [firefox#2]错误:听EACCES   exports._errnoException(util.js:746:11)中的[firefox#2]   Server._listen2上的[firefox#2](net.js:1112:19)   [firefox#2]在听(net.js:1155:10)   Server.listen上的[firefox#2](net.js:1240:5)   isFree上的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ net \ portprober.js:165:10)   findPort上的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ net \ portprober.js:197:7)   [firefox#2]在d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ net \ portprober.js:186:5   [fire object#2]在[object Object] .promise.ControlFlow.runInFrame_(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ lib \ webdriver \ promise.js:1877: 20)   [object object]上的[firefox#2] .promise.Callback_.goog.defineClass.notify(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ lib \ webdriver \ promise。 JS:2464:25)   [object object]上的[firefox#2] .promise.Promise.notify_(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ lib \ webdriver \ promise.js:563: 12)   [firefox#2]来自:任务:WebDriver.createSession()   [firefox#2]在Function.webdriver.WebDriver.acquireSession_(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ lib \ webdriver \ webdriver.js:155:22)   [firefox#2]在Function.webdriver.WebDriver.createSession(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ lib \ webdriver \ webdriver.js:129:30)   新驱动程序的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ selenium-webdriver \ firefox \ index.js:272:36)   [object object]上的[firefox#2] .DirectDriverProvider.getNewDriver(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ lib \ driverProviders \ direct.js:75:16)   [object object]上的[firefox#2] .Runner.createBrowser(d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ lib \ runner.js:180:37)   [firefox#2]在d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ lib \ runner.js:257:21   _fulfilled中的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ q \ q.js:797:54)   self.promiseDispatch.done上的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ q \ q.js:826:30)   Promise.promise.promiseDispatch上的[firefox#2](d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ q \ q.js:759:13)   [firefox#2]在d:\ Users \ Saifur \ AppData \ Roaming \ npm \ node_modules \ protractor \ node_modules \ q \ q.js:573:44

     

[launcher] Runner进程意外退出,错误代码为:1   [launcher] WebDriver的1个实例仍在运行

     

..

     

[chrome#1] PID:8084   [chrome#1]规格:e:\ working \ protractor-e2e \ specs \ smoke \ giftengHomePageTests.js   [chrome#1]   [chrome#1]直接使用ChromeDriver ......   [chrome#1] gifteng页面   [chrome#1]应该弹出登录模态框 - 通过   [chrome#1]警告 - 找到定位器By.xpath的多个元素(" // img [contains(@src,' welcome / gift.jpg')]") - 将使用第一个结果   [chrome#1]应导航到gifteng Give page - pass   [chrome#1]   [chrome#1]   [chrome#1]在7.522秒内完成   [chrome#1] 2次测试,2次断言,0次失败   [chrome#1]   [launcher] WebDriver的0个实例仍在运行   [launcher] firefox#2因退出代码失败:1   [launcher] chrome#1通过了   [launcher]整体:1个进程未能完成   [launcher]进程已退出,错误代码为100

     

处理以退出代码100

结束

2 个答案:

答案 0 :(得分:0)

您缺少告诉您的配置在哪里找到chromeDriver的行:

exports.config = {
        directConnect: true,
        chromeDriver: '/chromedriver/chromedriver_win32/chromedriver.exe',
....

答案 1 :(得分:0)

在配置文件中添加 baseUrl

directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine2',
  jasmineNodeOpts: {
    showColors: true,
    onComplete: null,
    defaultTimeoutInterval: 500000,
    print: function () { }
  }

这可能是原因