Note that I am using OS X 10.8.3 so YMMV.
Install PHPUnit
pear channel-discover pear.symfony.com
sudo pear install pear.symfony.com/Yaml
sudo pear install --alldeps pear.phpunit.de/PHPUnit
Install Selenium extension for PHPUnit
sudo pear install phpunit/PHPUnit_Selenium
Here’s a test to show you how to use Selenium to go to google with a firefox driver and enter in a search query, just as an example
<?php
class TestGoogle extends PHPUnit_Extensions_Selenium2TestCase {
public function setUp(){
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowser('firefox');
$this->setBrowserUrl('http://google.com');
}
public function testEnterText(){
$this->url("/");
//if the next line ever causes the test to fail, check that the class name of the input on google.com is still gbqfif
$text = $this->byClassName('gbqfif')->value('Selenium Made Me Do It!!');
//on the next line replace @USERNAME with your username or it probably will fail, you can always remove this line if you do not want a screenshot
$this->screenshot('/Users/@USERNAME/screenshot.'.time().'.png');
}
public function screenshot($filepath) {
$filedata = $this->currentScreenshot();
file_put_contents($filepath, $filedata);
}
}
It should return something like this:
Have fun testing!

