我正在使用docker,在第一个标签上运行selenium,在第二个项目上,第三个我运行量角器测试。量角器的配置文件:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js'],
framework: 'jasmine',
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--no-sandbox', '--disable-gpu', '--enable-logging=stderr', '--user-data-dir=/usr/src/app'],
},
},
onPrepare: function() {
var SpecReporter = require('jasmine-spec-reporter');
// add jasmine spec reporter
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
},
jasmineNodeOpts: {
print: function() {}
}
};
第一轮测试没问题,以下是日志:
Selenium Server is up and running
16:35:20.651 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --disable-gpu, --enable-logging=stderr, --user-data-dir=/usr/src/app]}}]])
16:35:20.699 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --disable-gpu, --enable-logging=stderr, --user-data-dir=/usr/src/app]}}]
Starting ChromeDriver 2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac) on port 3980
Only local connections are allowed.
16:35:26.862 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --disable-gpu, --enable-logging=stderr, --user-data-dir=/usr/src/app]}}]]
16:35:27.043 INFO - Executing: [set script timeout: 11000])
16:35:27.224 INFO - Done: [set script timeout: 11000]
16:35:32.447 INFO - Executing: [get: http://localhost:3000/keystone])
16:35:35.632 INFO - Done: [get: http://localhost:3000/keystone]
16:35:35.773 INFO - Executing: [find element: By.cssSelector: *[name="email"]])
16:35:36.606 INFO - Done: [find element: By.cssSelector: *[name="email"]]
16:35:36.657 INFO - Executing: [send keys: 0 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: *[name="email"]], [m, c, g, l, a, b, s, @, g, m, a, i, l, ., c, o, m]])
16:35:37.137 INFO - Done: [send keys: 0 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: *[name="email"]], [m, c, g, l, a, b, s, @, g, m, a, i, l, ., c, o, m]]
16:35:37.179 INFO - Executing: [find element: By.cssSelector: *[name="password"]])
16:35:37.249 INFO - Done: [find element: By.cssSelector: *[name="password"]]
16:35:37.282 INFO - Executing: [send keys: 1 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: *[name="password"]], [p, a, s, s, w, o, r, d]])
16:35:37.936 INFO - Done: [send keys: 1 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: *[name="password"]], [p, a, s, s, w, o, r, d]]
16:35:37.985 INFO - Executing: [find element: By.cssSelector: button[type="submit"]])
16:35:38.114 INFO - Done: [find element: By.cssSelector: button[type="submit"]]
16:35:38.327 INFO - Executing: [click: 2 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: button[type="submit"]]])
16:35:39.094 INFO - Done: [click: 2 [[ChromeDriver: chrome on LINUX (409a6b2de12c89405755981b76346cb0)] -> css selector: button[type="submit"]]]
16:35:39.153 INFO - Executing: [get: http://localhost:3000/keystone/properties/])
16:35:40.447 INFO - Done: [get: http://localhost:3000/keystone/properties/]
16:35:40.483 INFO - Executing: [find element: By.cssSelector: .btn-create-item])
16:35:42.420 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".btn-create-item"}
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.4.27-moby x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.23 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
*** Element info: {Using=css selector, value=.btn-create-item}
Session ID: 409a6b2de12c89405755981b76346cb0
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/usr/src/app, chromedriverVersion=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=55.0.2883.87, pageLoadStrategy=normal, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:492)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
at com.sun.proxy.$Proxy1.findElement(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.findElement(EventFiringWebDriver.java:188)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
16:35:42.702 WARN - Exception: no such element: Unable to locate element: {"method":"css selector","selector":".btn-create-item"}
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.4.27-moby x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.23 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
*** Element info: {Using=css selector, value=.btn-create-item}
Session ID: 409a6b2de12c89405755981b76346cb0
但是当我第二次进行protactor测试时,我得到了:
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=/usr/src/app, chromedriverVersion=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=55.0.2883.87, pageLoadStrategy=normal, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true}]
16:38:43.511 INFO - Executing: [new session: Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --disable-gpu, --enable-logging=stderr, --user-data-dir=/usr/src/app]}}]])
16:38:43.529 INFO - Creating a new session for Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --disable-gpu, --enable-logging=stderr, --user-data-dir=/usr/src/app]}}]
Starting ChromeDriver 2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac) on port 20127
Only local connections are allowed.
Created new window in existing browser session.
16:39:44.925 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
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:204)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
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.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
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(FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.4.27-moby x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.28 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
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
16:39:44.939 WARN - Exception: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.26.436382 (70eb799287ce4c2208441fc057053a5b07ceabac),platform=Linux 4.4.27-moby x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.28 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '9c29ea21cf96', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.27-moby', java.version: '1.7.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Exception: unknown error: Chrome failed to start: exited abnormally
看起来selenium尝试连接到chromeDriver但没有成功。你有什么建议问题的原因是什么?