webdriver-test Extension using Selenium WebDriver for functional tests

  1. Requirements
  2. Usage
  3. Resources

This extensions allows to run functionaln tests using WebDriver functions from Selenium Server 2.0. WebDriver runs as a plugin in remote browser, so it is much more reliable than standard Selenium test injected through JavaScript.

Extension is using PHP WebDriver Bindings project from http://code.google.com/p/php-webdriver-bindings/

Requirements

Requires PHP WebDriver Bindings (they are packaged in this extension) and Selenium Server 2.0 as tests runtime environment. Should work with Firefox and Chrome browsers (they are supported by Selenium WebDriver)

Usage

Extract archive in your extensions directory. Write functional test that extend CWebDriverTestCase in your tests/functional directory as usual.

Example:

Yii::import( 'ext.webdriver-bindings.CWebDriverTestCase' );

class ExampleTest extends CWebDriverTestCase {

	protected function setUp() {
		parent::setUp( 'localhost', 4444, 'firefox' );
	}

	public function testGoogle() {
		$this->get( 'http://www.google.com/' );
		
		$qElem = $this->findElementBy( LocatorStrategy::name, 'q' );
		$this->assertNotNull( $qElem, 'There is no "query" element!' );
		
		$qElem->sendKeys( array( 'yii framework' ) );
		
        $qElem->submit();
        sleep( 1 );
		
        $elem = $this->findElementBy( LocatorStrategy::className, 'vsc' );
		$this->assertNotNull( $elem, 'Results not found!' );
		
        $this->assertTrue( $this->isTextPresent( 'Yii Framework' ), 'The is no "Yii Framework" text on result page!' );
    }
}

or other way (based on CDbTestCase instead of WebTestCase):

define( 'TEST_BASE_URL', 'http://www.google.com/' );
Yii::import( 'ext.webdriver-bindings.CWebDriverDbTestCase' );

class ExampleDbTest extends CWebDriverDbTestCase {

    public $baseUrl = TEST_BASE_URL;

    public function testGoogle() {
        $this->get( 'http://www.google.com/' );

        $qElem = $this->findElementBy( LocatorStrategy::name, 'q' );
        $this->assertNotNull( $qElem, 'There is no "query" element!' );

        $qElem->sendKeys( array( 'yii framework' ) );

        $qElem->submit();
        sleep( 1 );

        $elem = $this->findElementBy( LocatorStrategy::className, 'vsc' );
        $this->assertNotNull( $elem, 'Results not found!' );

        $this->assertTrue( $this->isTextPresent( 'Yii Framework' ), 'The is no "Yii Framework" text on result page!' );
    }
}

Resources

12 0
24 followers
3 804 downloads
Yii Version: 1.1
License: Apache-2.0
Category: Others
Developed by: Maciej Liżewski
Created on: Jul 13, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions