getting selenuim 3.0.1 to work with phpunit 2.53 and java 1.8.0_121

179 views
Skip to first unread message

Bill Tangren

unread,
Feb 27, 2017, 9:32:29 AM2/27/17
to Selenium Users
I am having a great deal of difficulty getting selenium 3.0.1 to work with phpunit 2.53 and java 1.8.0_121. I have installed:

php 5.6.30 (as part of a Fedora 24 VM)
java 1.8.0_121-b14
firefox 51.0.1-2
selenium standalone server 3.0.1
phpunit 5.7.13
geckodriver 0.14.0
facebook webdriver 1.3.0

Everything that should be in the path is:

echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin/selenium:/usr/local/bin/phpunit:/usr/local/bin/composer:/usr/local/bin/geckodriver

This is what I get when I start selenium:

[bjt@localhost ~]$ java -Dwebdriver.gecko.driver="/usr/local/bin/geckodriver/geckodriver" -jar /usr/local/bin/selenium/selenium-server-standalone.0.1.jar
09:11:24.814 INFO - Selenium build info: version: '3.0.1', revision: '1969d75'
09:11:24.816 INFO - Launching a standalone Selenium Server
2017-02-27 09:11:24.893:INFO::main: Logging initialized @827ms
09:11:25.076 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
 registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
09:11:25.077 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
 registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
09:11:25.077 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:11:25.077 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
09:11:25.077 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:11:25.078 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
09:11:25.079 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 LINUX
2017-02-27 09:11:25.257:INFO:osjs.Server:main: jetty-9.2.15.v20160210
2017-02-27 09:11:25.346:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@6d8a00e3{/,null,AVAILABLE}
2017-02-27 09:11:25.431:INFO:osjs.ServerConnector:main: Started ServerConnector@548a9f61{HTTP/1.1}{0.0.0.0:4444}
2017-02-27 09:11:25.432:INFO:osjs.Server:main: Started @1366ms
09:11:25.432 INFO - Selenium Server is up and running

There are warnings, but not about any browser I'm using.

Here is a simple php file I'm trying to execute:

<?php
   require_once('/usr/local/bin/composer/vendor/autoload.php');
   class test extends PHPUnit_Extensions_Selenium2TestCase
   {
      protected function setUp()
      {
      $this->setBrowser("*firefox");

      $this
->setBrowserUrl("https://fakeurl.com/");

      }
      public function testMyTestCase()
      {
      $this
->open("/");

      }
   }
?>

When I run this test:

[bjt@localhost projects]$ /usr/local/bin/phpunit/phpunit-5.7.13.phar -vvv test.php

I get the following:

    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    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:131)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:36)
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
    at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:189)
    at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:222)
    at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:184)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:150)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808)
    at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    at org.seleniumhq.jetty9.server.Server.handle(Server.java:499)
    at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310)
    at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.WebDriverException: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{browserName=*firefox}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.10-100.fc24.x86_64', java.version: '1.8.0_121'
Driver info: driver.version: unknown
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:62)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:209)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more
09:21:27.741 WARN - Exception: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{browserName=*firefox}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.10-100.fc24.x86_64', java.version: '1.8.0_121'
Driver info: driver.version: unknown

phpunit threw a similar error:

[bjt@localhost projects]$ /usr/local/bin/phpunit/phpunit-5.7.13.phar -vvv test.php
PHPUnit 5.7.13 by Sebastian Bergmann and contributors.

Runtime:       PHP 5.6.30

E                                                                   1 / 1 (100%)

Time: 1 second, Memory: 12.50MB

There was 1 error:

1) test::testMyTestCase
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{browserName=*firefox}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.10-100.fc24.x86_64', java.version: '1.8.0_121'
Driver info: driver.version: unknown

/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:72
/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Isolated.php:67
/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:296
/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:337
/usr/local/bin/composer/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:314

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


It does not appear that java, selenium server, and phpunit are communicating properly.

Can someone tell me what I'm doing wrong and how to correct this?

Thanks.

Bill Tangren

unread,
Feb 27, 2017, 12:17:41 PM2/27/17
to Selenium Users
I should also mention that I have composer installed and I used it to install webdrivers facebook and phpunit/selenium.

The composer.json file is a follows:

{
    "require": {
        "facebook/webdriver": "^1.3",
        "phpunit/phpunit": ">=3.7",
        "phpunit/phpunit-selenium": ">=1.2"
    }
}

The errors you see below came from the code in these webdrivers.

David

unread,
Feb 28, 2017, 4:40:43 PM2/28/17
to Selenium Users
Did you also post (issue, etc.) to those projects themselves? The developers there can likely help you better. But my hunch could be that there might need to be a tweak in how you define the DesiredCapabilities. Has that changed for Firefox in Selenium 3?

In the interim, you could also try a different browser (Chrome, IE, Safari) and see if those crap out too or if it's just Firefox.

Bill Tangren

unread,
Feb 28, 2017, 5:01:10 PM2/28/17
to Selenium Users
I've posted to this group, stackoverflow, and giorgiosironi/phpunit-selenium (the makers of the webdriver). No response elsewhere. Yet.

And I have tried Chrome. I got the exact same error message, even after installing the chromedriver. 

Bill Tangren

unread,
Feb 28, 2017, 5:06:47 PM2/28/17
to Selenium Users
I was hoping someone here had already run into this issue and solved it. That's why I posted the problem. 

I don't know about DesiredCapabilities. But I do know that phpunit 5.x handles selenium test cases in a fundamentally different way than phpunit 4.x. Also, selenium 3 requires geckodriver/chromedriver, which selenium 2 did not.


On Tuesday, February 28, 2017 at 4:40:43 PM UTC-5, David wrote:

Bill Tangren

unread,
Mar 1, 2017, 10:46:21 AM3/1/17
to Selenium Users
Can anyone provide ANY example of phpunit >= 5.x that successfully opens a web browser using selenium 3.x on a Linux box? I've looked at:

https://testingbot.com/support/getting-started/phpunit.html
https://www.sitepoint.com/using-the-selenium-web-driver-api-with-phpunit/
http://codeception.com/11-12-2013/working-with-phpunit-and-selenium-webdriver.html

and several others. None of them work, at least not for me. Please?

John Dee

unread,
Jun 21, 2018, 2:30:03 PM6/21/18
to Selenium Users
I'm a WordPress dev. No problem with the latest versions using CodeCeption [which uses PHPunit as it's core]

John Dee

unread,
Aug 18, 2018, 3:19:43 PM8/18/18
to Selenium Users


On Thursday, June 21, 2018 at 11:30:03 AM UTC-7, John Dee wrote:
I'm a WordPress dev. No problem with the latest versions using CodeCeption [which uses PHPunit as it's core]
Reply all
Reply to author
Forward
0 new messages