使用Selenium Server运行量angular器testing时遇到问题

试图运行量angular器/茉莉花/seleniume2etesting

尝试使用独立的Selenium服务器和chrome驱动程序使用量angular器来运行e2etesting。

警告 – exception:C:\ Users \ ARM678 \ AppData \ Local \ Temp \ jna – 1409357381 \ jna1939368593138214681.dll:%1我尝试使用量angular器运行testing时出现以下Selenium服务器错误不是有效的Win32应用程序

这里有一些细节…

我通过在命令行执行如下(通过chrome web驱动程序位置)来启动Selenium独立服务器:

命令

java -jar selenium-server-standalone-2.52.0.jar -Dwebdriver.chrome.driver="C:\TDAWare\servers\selenium\drivers\chromedriver.exe" 

输出(看起来不错):

 14:00:27.695 INFO - Launching a standalone Selenium Server Setting system property webdriver.chrome.driver to C:\TDAWare\servers\selenium\drivers\chromedriver.exe 14:00:27.845 INFO - Java: Oracle Corporation 25.72-b15 14:00:27.846 INFO - OS: Windows 7 6.1 x86 14:00:27.855 INFO - v2.52.0, with Core v2.52.0. Built from revision 4c2593c 14:00:27.918 INFO - Driver class not found: com.opera.core.systems.OperaDriver 14:00:27.918 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered 14:00:27.925 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform VISTA 14:00:28.100 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 14:00:28.100 INFO - Selenium Server is up and running 

量angular器conf.js文件:

 exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['tdau-homepage-spec.js'], allScriptsTimeout: 200000, jasmineNodeOpts: { defaultTimeoutInterval: 200000, showColors: true, print: function() {} }, onPrepare: function() { var SpecReporter = require('jasmine-spec-reporter'); jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'})); } } 

量angular器tdau-homepage-spec.js

 'use strict'; describe('My first test suite', function() { it('should bring up a web page', function() { browser.get('https://internal.tdameritradeu.com/dist'); expect(browser.getTitle()).toEqual('TD Ameritrade U'); }); }); 

运行testing(一切都中断):

 protractor conf.js 

我得到以下2堆栈跟踪。 第一个来自Selenium服务器。 二是来自量angular器。

从Selenium服务器:

 14:08:22.142 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome, platform=WINDOWS}]]) 14:08:22.154 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome, platform=WINDOWS}] Starting ChromeDriver 2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 38568 Only local connections are allowed. 14:08:24.161 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42' System info: host: 'ILOL-F8VN662', ip: '10.20.102.66', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_72' Driver info: driver.version: unknown at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183) at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119) at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95) at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124) at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59) at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1) at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111) at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79) at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:202) at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:164) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:130) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680) at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571) at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526) at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479) at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920) at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820) at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986) at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837) at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243) at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358) at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537) Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42' System info: host: 'ILOL-F8VN662', ip: '10.20.102.66', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_72' Driver info: driver.version: unknown at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113) at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97) at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60) at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222) at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1) at java.util.concurrent.FutureTask.run(Unknown Source) at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103) ... 9 more Caused by: java.lang.UnsatisfiedLinkError: C:\Users\ARM678\AppData\Local\Temp\jna--1409357381\jna1939368593138214681.dll: %1 is not a valid Win32 application at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at java.lang.System.load(Unknown Source) at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761) at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736) at com.sun.jna.Native.<clinit>(Native.java:131) at org.openqa.selenium.os.Kernel32.<clinit>(Kernel32.java:34) at org.openqa.selenium.os.ProcessUtils.killWinProcess(ProcessUtils.java:133) at org.openqa.selenium.os.ProcessUtils.killProcess(ProcessUtils.java:81) at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.destroyHarder(UnixProcess.java:247) at org.openqa.selenium.os.UnixProcess$SeleniumWatchDog.access$2(UnixProcess.java:246) at org.openqa.selenium.os.UnixProcess.destroy(UnixProcess.java:125) at org.openqa.selenium.os.CommandLine.destroy(CommandLine.java:155) at org.openqa.selenium.remote.service.DriverService.stop(DriverService.java:196) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:94) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701) at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:526) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:134) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138) ... 14 more 14:08:24.188 WARN - Exception: C:\Users\ARM678\AppData\Local\Temp\jna--1409357381\jna1939368593138214681.dll: %1 is not a valid Win32 application 

从量angular器我得到以下堆栈跟踪:

 λ protractor conf.js Using the selenium server at http://localhost:4444/wd/hub [launcher] Running 1 instances of WebDriver C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108 var template = new Error(this.message); ^ UnknownError: C:\Users\ARM678\AppData\Local\Temp\jna--1409357381\jna1939368593138214681.dll: %1 is not a valid Win32 application at new bot.Error (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18) at Object.bot.response.checkResponse (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9) at C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:160:24 at [object Object].promise.Promise.goog.defineClass.invokeCallback_ (C:/TDAWare/servers/node/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1337:14) at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (C:/TDAWare/servers/node/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14) at [object Object].promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (C:/TDAWare/servers/node/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21) at goog.async.run.processWorkQueue (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15) at process._tickCallback (node.js:368:9) From: Task: WebDriver.createSession() at Function.webdriver.WebDriver.acquireSession_ (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:157:22) at Function.webdriver.WebDriver.createSession (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:131:30) at [object Object].Builder.build (C:\TDAWare\servers\node\node_modules\protractor\node_modules\selenium-webdriver\builder.js:445:22) at [object Object].DriverProvider.getNewDriver (C:\TDAWare\servers\node\node_modules\protractor\lib\driverProviders\driverProvider.js:42:27) at [object Object].Runner.createBrowser (C:\TDAWare\servers\node\node_modules\protractor\lib\runner.js:190:37) at C:\TDAWare\servers\node\node_modules\protractor\lib\runner.js:280:21 at _fulfilled (C:\TDAWare\servers\node\node_modules\protractor\node_modules\q\q.js:834:54) at self.promiseDispatch.done (C:\TDAWare\servers\node\node_modules\protractor\node_modules\q\q.js:863:30) at Promise.promise.promiseDispatch (C:\TDAWare\servers\node\node_modules\protractor\node_modules\q\q.js:796:13) at C:\TDAWare\servers\node\node_modules\protractor\node_modules\q\q.js:556:49 [launcher] Process exited with error code 1 

我的想法…

我相信这个问题的根本原因可以在Selenium堆栈跟踪中find

 14:08:24.188 WARN - Exception: C:\Users\ARM678\AppData\Local\Temp\jna--1409357381\jna1939368593138214681.dll: %1 is not a valid Win32 application 

我认为,当它试图利用chromedriver.exe时,铬驱动程序创build一个名为jna1939368593138214681.dll的dll文件,由于某种原因,Windows不喜欢该文件[一个明智的演绎看到这正是错误说的]

我试过了:

  • 我已经尝试重新下载驱动程序,以确保下载不会损坏zip文件
  • 我已经尝试过不同版本的驱动程序。
  • 我已经尝试解压缩与2个不同的zip实用程序(winzip和winrar)的驱动程序zip文件,以确保解压缩过程不会破坏任何东西

环境

  • 操作系统:Windows 7企业版
  • types:64位
  • chromedriver版本:2.21(也试过v.2.16)
  • 节点版本:4.2.4
  • npm版本:3.7.5

注意 – Google明确指出,chrome只有32位版本的驱动程序,并指出64位系统将与32位驱动程序一起工作,并且没有可用的64位驱动程序。

您的配置文件缺少capabilities 。 您将需要告诉量角器使用哪个驱动程序: browserName: 'chrome'

 exports.config = { framework: 'jasmine', seleniumAddress: 'http://localhost:4444/wd/hub', capabilities: { browserName: 'chrome' }, specs: ['tdau-homepage-spec.js'], allScriptsTimeout: 200000, jasmineNodeOpts: { defaultTimeoutInterval: 200000, showColors: true, print: function() {} }, onPrepare: function() { var SpecReporter = require('jasmine-spec-reporter'); jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'})); } }