Skip to content
This repository

PHP interaction with Selenium Webdriver API

branch: master


latest commit dc4252830c
Polo Santiago polosantiago authored
Octocat-spinner-32 demo Adding nav methods to demo December 19, 2013
Octocat-spinner-32 src Magic methods' comments December 11, 2013
Octocat-spinner-32 test Changing sandbox url December 17, 2013
Octocat-spinner-32 .gitignore Gitignore entry October 07, 2013
Octocat-spinner-32 Space December 19, 2013
Octocat-spinner-32 composer.json Excluding demo and tests directories for composer December 12, 2013


PHP interaction with Selenium Webdriver API


This library allows the interaction with Selenium Server V2 in PHP. It communicates with the WebDriver API through the official JsonWireProtocol.

One of the goals is to provide a client usage as close as possible to the Selenium Official libraries (such as Java's, c#'s). Most methods are named as the same as of these libraries'. In this way, whenever a developer runs into ideas or documentation in Java Client, the same techniques can be implemented by using this library.


Version 2

Version 1


  • Start a session by creating an instance of WebDriver. By default, the test will run in firefox

    $driver = new WebDriver();
  • As an alternative you can define desired capabilities for the session

    $desiredCapabilities = new DesiredCapabilities("chrome");
    $driver = new WebDriver($desiredCapabilities);
  • Navigate by using the WebDriver::get method from the WebDriver Class

  • Get elements from the DOM in current location

    $textbox1 = $driver->findElement(By::id("someTextBoxId"));
    $button1 = $driver->findElement(By::cssSelector("html body div#content input#someButtonId"));
  • Manipulate located elements

    $textbox1->sendKeys("Some text to send");
  • Find element within elements

    $listItems = $modal1->findElements(By::tagName("li"));
  • Switch between windows

  • Manage alerts $alert = $driver->switchTo()->alert(); $alert->getText(); $alert->accept(); $alert->dismiss();

  • Wait for elements to be present

    $webElement = $driver->waitForElementUntilIsPresent(By::id("someElementId"));
    $wait = new WebDriverWait(8);
    $webElement = $wait->until($driver,"findElement",array(By::id("someElementId"),true));
Something went wrong with that request. Please try again.