Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Wednesday, March 7, 2012
Selenium 2 (WebDriver) and Phpunit?
Any one know how to use Selenium 2 with Phpunit? Are there any Selenium 2 samples in PHP?
please look at the http://code.google.com/p/php-webdriver-bindings/ . This is PHP library that communicates with Selenium Webdriver server using JsonWireProtocol. This is early version but it works.
At the time of writing, PHPUnit does not support Selenium 2.
php-webdriver from facebook allows the complete WebDriver API to be called from PHP in an elegant way. To quote:
Most clients require you to first read the protocol to see what's possible, then study the client itself to see how to call it. This hopes to eliminate the latter step.
It is used by starting up the Selenium 2 server, which provides the interface at localhost:4444/wd/hub.
PHPUnit Selenium integration code lives as a separate project in github, as far as I can see it does not support Selenium 2, so the answer to your question would be - No, you can not use Selenium 2 with PHPUnit.
But you can clone the source tree and make it work with Selenium 2.
phpunit webdriver bindings are hosted on google code. There is something we need to understand beyond this.
PHPUnit needs to be installed. (Either through PEAR package or download and install manually) PHP IDE such as Eclipse PDT has to be downloaded and installed. Selenium-Stand-Alone server has to be running while executing the WebDriver Selenium test
please look at the http://code.google.com/p/php-webdriver-bindings/ . This is PHP library that communicates with Selenium Webdriver server using JsonWireProtocol. This is early version but it works.
ReplyDeleteAt the time of writing, PHPUnit does not support Selenium 2.
ReplyDeletephp-webdriver from facebook allows the complete WebDriver API to be called from PHP in an elegant way. To quote:
Most clients require you to first read the protocol to see what's
possible, then study the client itself to see how to call it. This
hopes to eliminate the latter step.
It is used by starting up the Selenium 2 server, which provides the interface at localhost:4444/wd/hub.
/usr/bin/java -jar /path/to/selenium-server-standalone-2.7.0.jar
then running the PHP test code, which calls that interface. For example:
<?php
require '/path/to/php-webdriver/__init__.php';
$webdriver = new WebDriver();
$session = $webdriver->session('opera', array());
$session->open("http://mysite.com");
$button = $session->element('id', 'my_button_id');
$button->click();
$session->close();
The WebDriver API is mapped to PHP methods, compare calling click on element in the example with the element/click API call in the documentation.
The test code can then be wrapped in regular phpUnit tests.
This is not native phpUnit support, but it's a quite robust approach.
PHPUnit Selenium integration code lives as a separate project in github, as far as I can see it does not support Selenium 2, so the answer to your question would be - No, you can not use Selenium 2 with PHPUnit.
ReplyDeleteBut you can clone the source tree and make it work with Selenium 2.
phpunit webdriver bindings are hosted on google code. There is something we need to understand beyond this.
ReplyDeletePHPUnit needs to be installed. (Either through PEAR package or download and install manually)
PHP IDE such as Eclipse PDT has to be downloaded and installed.
Selenium-Stand-Alone server has to be running while executing the WebDriver Selenium test