Setup Selenium Web driver on WAMP environment


Recently I configured Selenium web driver on multiple systems having WAMP environment. There’s an excellent tutorial for it here. However I had to do some additional configurations mentioned below.

Step 2.1 mentioned there is a bit tricky, you may have to try these

pear clear-cache

pear install -a -f phpunit/PHPUnit

Source: http://stackoverflow.com/questions/6272264/windows-installing-phpunit-via-pear-installing-phpunit-via-pear

pear install –force phpunit/PHPUnit_Selenium

Source: http://stackoverflow.com/questions/8495839/phpunit-not-recognizing-curl-extension-cant-install-selenium-test

Also make sure that cURL is working. You may have to replace your curl extension file

http://stackoverflow.com/questions/10939248/php-curl-not-working-wamp-on-windows-7-64-bit

Also WAMP contains multiple php.ini files

  1. /wamp/bin/php/php5.x.x
  2. /wamp/bin/apache/apache2.x.x/bin

Make sure to enable cURL in both the files so that PHP CLI picks the cURL extension

Integrate Web Driver

Selenium Webdriver doesn’t support PHP. However there are several third party implementations. I prefer https://github.com/facebook/php-webdriver. Download the repo and copy the lib folder in your tests folder. Here’s a sample file that you can use to verify your installation

<?php

require_once('lib/__init__.php');

class First extends PHPUnit_Framework_TestCase {

protected function setUp() {
$host = 'http://localhost:4444/wd/hub'; // this is the default
$capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'firefox');
$this->driver = RemoteWebDriver::create($host, $capabilities, 1000);
}

public function testLogin(){

$this->driver->get('http://localhost/mysite/');

}
?>

Run command “phpunit first.php First”. This would open a firefox window and navigate to http://localhost/mysite/.

Extend the script using both the Selenium webdriver API and PHP Unit assertions.

Advertisements

I am a web developer working @ Gaditek

Tagged with: , , , , , ,
Posted in PHP, Programming & Development

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About me
A geek trying to make world a better place to live.

I mostly work on Web Technologies like PHP, Javascript. I also work on Python, GAE and Netsuite Customization. Currently working @ Cloudways

Profile Links Linkedin | Github | Stackoverflow
Subscribe to this blog
%d bloggers like this: