構成: Mac OS X 10.8.5、Java 1.6.0_65、Selenium 2.37、Jenkins 1.538、Chrome 30.0.1599.101、ChromeDriver v2.6.232908、Firefox 25.0。PHPUnit 3.7.28 および PHP 5.3.22 (PHPUnit_Extensions_Selenium2TestCase を使用) を使用してテストを実行しています。
(1) Selenium を次のように手動で起動した場合:
$ java -jar ~/Downloads/selenium-server-standalone-2.37.0.jar -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver
期待どおりにテストを実行できます。
(2) ただし、Jenkins 経由で Selenium を起動すると:
# launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
そして、私のテストを実行すると、エラーが発生します:
$ phpunit --verbose tests/classes/core/admin_campaignhome_loads.php
PHPUnit 3.7.28 by Sebastian Bergmann.
E
Time: 20.56 seconds, Memory: 5.25Mb
There was 1 error:
1) AdminTest::testLoginToBackend
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.6.232908,platform=Mac OS X 10.8.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.53 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'Pauls-iMac.local', ip: '192.168.1.18', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver
/usr/local/php5-20130308-201415/lib/php/PHPUnit/TextUI/TestRunner.php:349
/usr/local/php5-20130308-201415/lib/php/PHPUnit/TextUI/Command.php:176
/usr/local/php5-20130308-201415/lib/php/PHPUnit/TextUI/Command.php:129
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
(3) Jenkins 経由の Firefox + Selenium により、期待どおりにテストを実行できます。
jenkins.log には次のものがあります。
14:51:11.439 INFO - Executing: [new session: {browserName=chrome}] at URL: /session)
14:51:11.440 INFO - Creating a new session for Capabilities [{browserName=chrome}]
Starting ChromeDriver (v2.6.232908) on port 33014
14:51:31.972 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'Pauls-iMac.local', ip: '192.168.1.18', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:176)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:112)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:104)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:205)
at org.openqa.selenium.remote.server.JsonHttpRemoteConfig.handleRequest(JsonHttpRemoteConfig.java:192)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:201)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:167)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:139)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
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:914)
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:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'Pauls-iMac.local', ip: '192.168.1.18', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:72)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:56)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:215)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:62)
... 9 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.6.232908,platform=Mac OS X 10.8.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.53 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'Pauls-iMac.local', ip: '192.168.1.18', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:150)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:129)
... 14 more
14:51:31.974 WARN - Exception: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.6.232908,platform=Mac OS X 10.8.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.53 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info: host: 'Pauls-iMac.local', ip: '192.168.1.18', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver