Updated: 2017-04-13 18:52:38 CST +08

Selenium with PHPUnit

Requirements

  • Java JDK
  • PHP
  • PHPUnit

WebDriver

  1. Install

Download And Install Selenium Standalone Server

http://docs.seleniumhq.org/download/

  1. Start
java -jar selenium-server-standalone-2.52.0.jar

Facebook PHP Web Driver

php composer.phar require facebook/webdriver

Integrate with PHPUnit

<?php

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;

class RegitsterTest extends PHPUnit_Framework_TestCase
{

    protected $webDriver;

    public function setUp()
    {
        $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', DesiredCapabilities::firefox());
    }

    public function tearDown()
    {
        $this->webDriver->quit();
    }
}

Example

https://github.com/dinos80152/php-tutorial/selenium

Tutorial

Documentation

http://facebook.github.io/php-webdriver/

Reference