Testing multiple browsers with Selenium2 in PHPUnit

You used to be able to run test on multiple browsers with PHPUnit Selenium test class by specifying a $browsers property. You can still do the same with PHPUnit’s Selenium 2 class made for web driver. Here is how you do it:

class SomeTest extends PHPUnit_Extensions_Selenium2TestCase
{
	/**
	 * Variable to specify which browsers to run the tests on
	 * @var array
	 */
	public static $browsers = [
		['browserName' => 'firefox'],
		['browserName' => 'chrome']	
	];

	public funciton __construct()
	{
		$this->setHost('localhost');
		$this->setPort(4444);
		$this->setSeleniumServerRequestsTimeout(60);
		$this->setDesiredCapabilities([]);
	}
	
	public function setUp()
	{
		$this->setBrowserUrl('http://moazzam-khan.com/');
	}

	/**
	 * This is just a test that will open a website in chrome and firefox
	 */
	public function testOpenSite()
	{
		$this->url('/');		
	}
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *