Executing and Creating Selenium RC automation test cases using PHPUnit (by Sebastian Bergmann)

June 4th, 2012

Garry
- Setup PHPUnit framework http://www.unclecode.com/2010/05/install-phpunit-on-wamp-xamp-manually-without-pear/ assuming PHP 5.2.x is already installed in your system. If not download wamp to install PHP or browse php.net download section to install PHP.
- Make sure your PHP path is set in your environment so that you can execute PHP through command prompt. For reference check step 3 and 4 of article http://www.unclecode.com/2010/05/install-phpunit-on-wamp-xamp-manually-without-pear/Download and install latest Java JRE (if does not exist on your system).
- Download Selenium server and start the server through following command on command prompt http://seleniumhq.org/download/
- The above steps are explained in http://www.unclecode.com/2012/05/how-to-setup-selenium-webdriver-and-execute-automation-script/
- Download and Install latest firefox
- Install Firefox Selenium IDE plugin http://seleniumhq.org/download/ under section Selenium IDE “Download version 1.8.0 released on 24/April/2012″
- Install Selenium PHP plugin to generate/export scripts of type PHPUnit framework https://addons.mozilla.org/en-US/firefox/addon/selenium-ide-php-formatters/
- Record script through Selenium IDE plugin
- Save the test suit and Export test case to PHPUnit framework through Selenium IDE export option under File menu
- Open command line and make sure phpunit is working by executing command “phpunit –version”
- Open the file which you have exported above in a editor and include the following line-
- require_once(‘PHPUnit/Extensions/SeleniumTestCase.php’);
- The name of the file (like PhpUnitSelenium.php) and class name should be same i.e. like-
class PhpUnitSelenium extends PHPUnit_Extensions_SeleniumTestCase
- Make sure your selenium running in a command prompt
- Now open another command prompt and browse to the directory where you have saved the exported test case file and execute the following command like-
C:\wamp\www\php-selenium-webdriver\tests>phpunit PhpUnitSelenium
- The above should open a new selenium firefox window to execute tests

You can
leave a response, or
trackback from your own site.
Leave a Reply