Selenium Webdriver bindings for PHP

2013 年 10 月 8 日5980

Project Information

Project feeds

Code license

Apache License 2.0

Labels

selenium,

webdriver,

php,

phpunit,

functional,

testing

Members

lukasz.k...@gmail.com,

maciej.l...@gmail.com

5 committers

Featured

Downloads

php-webdriver-bindings-0.9.0.zip

Show all &raquo

Wiki pages

DifferenceBetweenWebdriverAndSelenium1

Show all &raquo

Links

External links

Selenium

Yii extension

Introduction

This is site for developers of PHP bindings for Selenium WebDriver. This PHP library allows creating functional webdriver tests with PHP.

Details

Library comunicates with Selenium Server using JsonWireProtocol. Requires curl in PHP. List of implemented methods: implemented_methods.

Example

require_once "phpwebdriver/WebDriver.php";



require("phpwebdriver/LocatorStrategy.php");







$webdriver = new WebDriver("localhost", "4444");



$webdriver->connect("firefox");



$webdriver->get("http://http://www.zjjv.com//");



$element = $webdriver->findElementBy(LocatorStrategy::name, "q");



$element->sendKeys(array("selenium google code" ) );



$element->submit();







$webdriver->close();



combobox handling

        $this->webdriver->get($this->test_url);



$element = $this->webdriver->findElementBy(LocatorStrategy::name, "sel1");



$option3 = $element->findOptionElementByText("option 3");



$option3->click();



$this->assertTrue($option3->isSelected());







$option2 = $element->findOptionElementByValue("2");



$option2->click();



$this->assertFalse($option3->isSelected());



$this->assertTrue($option2->isSelected());

Use your existing Selenium1 tests (also generated with Selenium IDE)

Use CWebDriverTestCase.php class which provides interface like classic selenium test class:

class WebTestCase extends CWebDriverTestCase



{



protected function setUp()



{



parent::setUp();



$this->setBrowserUrl('http://http://www.zjjv.com//');



}







/** generate screenshot if any test has failed */



protected function tearDown()



{



if( $this->hasFailed() ) {



$date = "screenshot_" . date('Y-m-d-H-i-s') . ".png" ;



$this->webdriver->getScreenshotAndSaveToFile( $date );



}



$this->close();



}







protected function testSomething( )



{



$this->open( "/index-test.php/user/login", "expect-div-with-this-id-after-load-page" );



$this->type( "LoginForm_username", "your_login" );



$this->type( "LoginForm_password", "your_pass" );



$this->click( "login-button" );







// getElement will try few times to find element



$this->getElement( LocatorStrategy::id, 'top-user-data' );







$this->assertTrue( $this->isTextPresent( "Logged as: your_pass" ) );



}



//...

Yii framework extension

Use Webdriver/Selenium2 in your Yii application: http://http://www.zjjv.com///extension/webdriver-test


This project is sponsored by: 3e software house

0 0