关闭selenium-webdriver连接时,量角器测试失败

时间:2015-11-11 08:58:16

标签: selenium-webdriver protractor appveyor gulp-protractor

问题

我试图让AppVeyor使用Protractor和Selenium-webdriver运行一些e2e测试。

在我的本地机器上一切正常,但是当在AppVeyor量角器上进行构建和测试时,由于selenium-webdriver中的一个未找到的方法,代码1退出了。我试图获得有关错误消息的一些信息,但我的搜索并没有让我到任何地方。大多数结果来自使用Java的后端测试。

以下是构建日志的片段:

node_modules\.bin\gulp protractor
[08:37:23] Using gulpfile C:\projects\kitos\gulpfile.js
[08:37:23] Starting 'protractor'...
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://10.240.0.18:63619/wd/hub
.. 

Finished in 42.225 seconds
2 tests, 2 assertions, 0 failures

C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108
  var template = new Error(this.message);
                 ^
UnknownError: Can't obtain updateLastError method for class com.sun.jna.Native
    at new bot.Error (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
    at Object.bot.response.checkResponse (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
    at C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
    at [object Object].promise.ControlFlow.runInFrame_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
    at [object Object].goog.defineClass.notify (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
    at [object Object].promise.Promise.notify_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
    at Array.forEach (native)
    at [object Object].promise.Promise.notifyAll_ (C:/projects/kitos/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
    at goog.async.run.processWorkQueue (C:\projects\kitos\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
    at process._tickCallback (node.js:368:9)
[launcher] Process exited with error code 1
[08:38:13] 'protractor' errored after 50 s
[08:38:13] Error in plugin 'gulp-protractor'
Message:
    protractor exited with code 1

selenium服务器正在运行,测试通过,但是当服务器即将关闭时,会发生错误。

设置

在构建开始时,我运行npm install,然后运行node_modules\\.bin\\webdriver-manager update --standalone作为安装后脚本。

量角器使用gulp-protractor插件执行gulp任务,并且量角器配置中定义了selenium独立jar,如下所示:

exports.config = {
    seleniumServerJar: '../node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',

    specs: ['Tests/**/*e2e.spec.js'],

    resultJsonOutputFile: 'results-protractor.json',

    allScriptsTimeout: 30000
};

完整的构建日志可以在这里看到:https://ci.appveyor.com/project/Crevil/kitos/build/1.0.187 为嘈杂的日志道歉。控制台中的部署日志记录非常响亮,并且无法在AppVeyor上进行配置。

本地日志信息

如上所述,我的本地计算机上的一切运行正常。这是量角器运行的日志。

C:\Users\BSO\Documents\Git repos\kitos>gulp protractor
[09:54:58] Using gulpfile ~\Documents\Git repos\kitos\gulpfile.js
[09:54:58] Starting 'protractor'...
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://192.168.5.153:16772/wd/hub
..

Finished in 5.241 seconds
2 tests, 2 assertions, 0 failures

Shutting down selenium standalone server.
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #1 passed
[09:55:08] Finished 'protractor' after 10 s

C:\Users\BSO\Documents\Git repos\kitos>

1 个答案:

答案 0 :(得分:1)

使用以下java运行时引擎参数解决此问题

localSeleniumStandaloneOpts: {
        args: ['-Djna.nosys=true']
},
...

protractor issue herespecific solution by Feodor Fitsner中有更多详细信息。