0
votes

I have created a number of selenium IDE files that I converted to phpunit format in Firefox IDE 2.9.1.1 (on a Windows box), using Options -> Format converter. Those converted files define a class "Example" that is derived from class PHPUnit_Extensions_SeleniumTestCase. I now know that this class needs to be changed to PHPUnit_Extensions_Selenium2TestCase. The problem is, I cannot get this to run with recent versions of phpunit.

I am running these tests on a Fedora 24 VM which is using php 5.6.30, java 1.8.0_121-b14, and firefox 51.0.1-2. I have tried to get these to run using selenium standalone server 3.0.1 (and now 3.1.0), and phpunit 5.7.13. I have the latest php facebook WebDriver installed. The error I keep getting is that the above mentioned class is not found. I did a grep on that class and this is what I found:

[root@localhost bin]# grep -r "PHPUnit_Extensions_Selenium2TestCase" .

Binary file ./phpunit/phpunit-4.6.7.phar matches

Binary file ./phpunit/phpunit-4.7.6.phar matches

So, it appears that this class does not exist in phpunit 5.7 and above (which are in that directory), nor does it exist in html-runner.phar, which is in the same directory. The seleniumhq.org site says to use html runner if you convert from IDE, but I can find no examples of how to use the html-runner.phar file (and no documentation).

Can someone please tell me what I should change the class name to, to get this test to work?

UPDATE:

I now know that if I want to use phpunit and selenium server to drive a firefox browser, I have to get selenium talking to geckodriver. I have installed:

geckodriver 0.14.0 at /usr/local/bin/geckodriver

selenium server 3.0.1 at /usr/local/bin/selenium

phpunit-5.7.13.phar installed at /usr/local/bin/phpunit

I used composer to add webdrivers (facebook 1.3.0 :

[root@localhost composer]# cat composer.json { "require": { "facebook/webdriver": "^1.3", "phpunit/phpunit": ">=3.7", "phpunit/phpunit-selenium": ">=1.2" } }

php composer.phar install

They were added to the PATH:

[bjt@localhost projects]$ 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

I have a small test file:

?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("/");

}

}

Starting the selenium server:

java -jar /usr/local/bin/selenium/selenium-standalone-3.0.1.jar

When I run the test:

/usr/local/bin/phpunit/phpunit-5.7.13.phar --verbose test.php

Yields this error:

PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{browserName=*firefox}]

So, it appears that geckodriver is not talking to selenium server. If I try to force the issue by changing the execution of the server:

java -Dwebdriver.gecko.driver="/usr/local/bin/geckodriver/geckodriver" -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar

or

sudo java -Dwebdriver.gecko.driver="/usr/local/bin/geckodriver/geckodriver" -jar /usr/local/bin/selenium-server-standalone-3.0.1.jar

It makes no difference. I'm hoping someone can point out what I am missing. I'm at a dead end.

1

1 Answers

0
votes

I am currently working through the same process of getting this to work and would like to point out a few things:

  • htmlrunner is meant to run the test cases saved directly from the Selenium IDE in the default format, which is html.
  • Make sure you can run firefox from the terminal running the selenium server.
  • You added two different selenium php bindings. The facebook one and the phpunit-selenium. I currently have it working with only the facebook binding and phpunit extending the class PHPUnit_Framework_TestCase. I would recommend using the example provided within github for facebook/webdriver without phpunit to verify that your selenium config is working, then add phpunit.