尝试使用独立的Selenium服务器和chrome驱动程序使用Protractor运行e2e测试。
当我尝试使用Protractor运行测试时,我收到以下Selenium服务器错误: 14:08:24.188 WARN - 异常:C:\ Users \ ARM678 \ AppData \ Local \ Temp \ jna - 1409357381 \ jna1939368593138214681.dll:%1不是有效的Win32应用程序
以下是一些细节......
我通过在命令行执行以下命令启动Selenium独立服务器(传递chrome web驱动程序位置):
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
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'}));
}
}
'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');
});
});
protractor conf.js
我得到以下2个堆栈跟踪。第一个来自Selenium Server。第二个来自量角器。
来自Selenium Server:
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
从量角器我得到以下Stack Trace:
λ 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堆栈跟踪中找到
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时,chrome驱动程序会创建一个名为jna1939368593138214681.dll的dll文件,由于某些原因,Windows并不喜欢该文件[这是一个很棒的演绎,可以看到&#39 ; s正是错误所说的]
注意 - Google明确声明chrome只有32位版本的驱动程序,并声明64位系统可以使用32位驱动程序而且没有64位驱动程序司机可用。
答案 0 :(得分:1)
您的配置文件丢失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'}));
}
}