Problems getting phpunit and selenium2 to work together.

301 views
Skip to first unread message

Bill Tangren

unread,
Jan 18, 2017, 9:52:17 PM1/18/17
to Selenium Users
First off, thank you for taking the time to read my post and answer my questions. I hope this is the correct place to pose this question. If not, my apologies. 

I am trying to get phpunit and selenium2 (with php facebook webdrivers) to work together to allow me to do remote control of a firefox browser to test our web site. I can't get it to work. These are the steps I've taken. Please take a look and let me know what I'm doing wrong. I am working on Windows 10 platform.

1) JAVA

I installed both 32 and 64 bit java SDK. I've attached a screenshot of the installed programs. I get this when I ask to see the version:

# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

2) XAMPP

I went to https://www.apachefriends.org/download.html and downloaded the 5.6.28 / PHP 5.6.28 version of xampp for Windows (32 bit). The control panel installed is version 3.2.2. Apache appears to start up just fine. I run it as admin. I've attached a screenshot.

3) COMPOSER

In case I needed it, I also did a manual download of Composer from https://getcomposer.org/download/. I successfully installed it. 

# composer -V
Composer version 1.3.1 2017-01-07 18:08:51

4) Selenium Server

I went to http://www.seleniumhq.org/download/ and downloaded selenium server standalone 3.0.1. I run it as admin. Except for problems with Safari and opera drivers, it also appears to run just fine. I've attached two screenshots showing the server install script runnning and the server console running. I don't know how to show it is actually working from the command line.

5) WEBDRIVER

I went to https://github.com/facebook/php-webdriver and downloaded php by facebook. From that page, I downloaded php-webdriver-community.zip. I extracted it to C:\xampp\php-webdriver-community. I then used my XAMPP console, went to that directory and ran "composer install". This errored out, with the following error:

******
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Writing lock file
Generating autoload files

  [RuntimeException]
  Could not scan for classes inside "tests/functional/" which does not appear to be a file nor a folder

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
******

Not sure whether how to demonstrate that it is working.

6) PHPUNIT

I went to https://phpunit.de/ and downloaded phpunit-5.7.5. I used http://unphar.com/ to convert from .phar to .zip. I then put all of those unpacked packages into c:\bin\phpunit. I then used https://phpunit.de/manual/current/en/phpunit-book.html#installation and followed the instructions to install phpunit.

# echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
# type phpunit.cmd
@php "%~dp0phpunit.phar" %*
# exit

After reopening an XAMPP command prompt, I got this:

C:\Users\Bill>phpunit -version
PHPUnit 5.7.5 by Sebastian Bergmann and contributors.
unrecognized option -- e

This is the path environment variable value:

C:\Users\Bill>path
PATH=c:\bin;C:\bin\phpunit;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Users\Bill\AppData\Roaming\Composer\vendor\bin;C:\Users\Bill\AppData\Local\Microsoft\WindowsApps;

7) SELENIUM TEST CASE

Chapter 17. PHPUnit and Selenium
Selenium Server

# phpunit ./seleniumtest.php
PHP Fatal error:  Class 'PHPUnit_Extensions_Selenium2TestCase' not found in C:\xampp\htdocs\seleniumtest.php on line 3

Fatal error: Class 'PHPUnit_Extensions_Selenium2TestCase' not found in C:\xampp\htdocs\seleniumtest.php on line 3

I've researched this error, and most of the google responses indicated that I had to give the path to the php file I'm running. But I'm running this from the directory the file is in. Giving it a .\filename doesn't help. I noticed that this test case came from the 3.7 version of the phpunit manual. Perhaps phpunit doesn't support selenium anymore? 

So, my main question now is: what am I doing wrong?

Thank you for any guidance you can provide.
Bill

installed programs.png
selenium server console.png
selenium server.png
xampp control panel.png

Bill Tangren

unread,
Jan 25, 2017, 8:12:58 AM1/25/17
to Selenium Users
I can tell you that I get this to work if I go back to an earlier version (pre-3.0) of selenium standalone server. It does not appear I can get either 3.0 or 3.0.1 to work with any version of phpunit. 

I hope that helps.

David

unread,
Jan 25, 2017, 4:01:30 PM1/25/17
to Selenium Users
That's interesting to know. What about the other PHP bindings? Like Facebook one or these


This does make me wonder if Selenium 3 has compatibility issues with 3rd party language bindings (or perhaps there's been a change in their JSONWireProtocol to which 3rd party language bindings implement against)
Reply all
Reply to author
Forward
0 new messages