Skip to content
A php client for webdriver.
Branch: community
Clone or download
gfosco Merge pull request #609 from gfosco/copyright-headers
Added a few more copyright headers.
Latest commit 2dbfa70 Oct 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Added a few more copyright headers. Oct 18, 2018
logs Send code coverage reports to coveralls.io Jan 7, 2017
tests Added a few more copyright headers. Oct 18, 2018
.coveralls.yml Send code coverage reports to coveralls.io Jan 7, 2017
.gitattributes [+]: ".gitattributes" <- prevent installing special files via composer Feb 1, 2016
.gitignore Add .vscode folder to .gitignore Feb 8, 2018
.php_cs.dist Add more php-cs-fixer rules Mar 14, 2018
.travis.yml Update Selenium to 3.8.1 and Chromedriver to 2.38 May 28, 2018
CHANGELOG.md
CODE_OF_CONDUCT.md Add `CODE_OF_CONDUCT.md` Nov 27, 2017
CONTRIBUTING.md Fix the name of a env var in CONTRIBUTING.md (#583) Jun 16, 2018
ISSUE_TEMPLATE.md Add issue template Jan 7, 2017
LICENSE.md Renamed license file. Oct 18, 2018
README.md Clarified README (#557) Apr 10, 2018
composer.json Use udiff format in php-cs-fixer for more readable diffs Mar 14, 2018
example.php Added copyright headers to 2 codefiles Oct 18, 2018
phpstan.neon Use PHPStan for static analysis Dec 11, 2017
phpunit.xml.dist Report test results to saucelabs API to show the results on their das… Feb 24, 2017

README.md

php-webdriver – Selenium WebDriver bindings for PHP

Latest Stable Version Travis Build Sauce Test Status Total Downloads License

Description

Php-webdriver library is PHP language binding for Selenium WebDriver, which allows you to control web browsers from PHP.

This library is compatible with Selenium server version 2.x and 3.x. It implements the JsonWireProtocol, which is currently supported by the Selenium server and will also implement the W3C WebDriver specification in the future.

The concepts of this library are very similar to the "official" Java, .NET, Python and Ruby bindings from the Selenium project.

As of 2013, this PHP client has been rewritten from scratch. Using the old version? Check out Adam Goucher's fork of it.

Looking for API documentation of php-webdriver? See https://facebook.github.io/php-webdriver/

Any complaints, questions, or ideas? Post them in the user group https://www.facebook.com/groups/phpwebdriver/.

Installation

Installation is possible using Composer.

If you don't already use Composer, you can download the composer.phar binary:

curl -sS https://getcomposer.org/installer | php

Then install the library:

php composer.phar require facebook/webdriver

Getting started

Start Server

The required server is the selenium-server-standalone-#.jar file provided here: http://selenium-release.storage.googleapis.com/index.html

Download and run the server by replacing # with the current server version. Keep in mind you must have Java 8+ installed to run this command.

java -jar selenium-server-standalone-#.jar

NOTE: If using Firefox, see alternate command below.

Create a Browser Session

When creating a browser session, be sure to pass the url of your running server.

// This would be the url of the host running the server-standalone.jar
$host = 'http://localhost:4444/wd/hub'; // this is the default
Launch Chrome

Make sure to have latest Chrome and Chromedriver versions installed.

$driver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
Launch Firefox

Make sure to have latest Firefox and Geckodriver installed.

Because Firefox (and Geckodriver) only support the new W3C WebDriver protocol (which is yet to be implemented by php-webdriver - see issue #469), the protocols must be translated by Selenium Server - this feature is partially available in Selenium Server versions 3.5.0-3.8.1 and you can enable it like this:

java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false

Now you can start Firefox from your code:

$driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox());

Customize Desired Capabilities

$desired_capabilities = DesiredCapabilities::firefox();
$desired_capabilities->setCapability('acceptSslCerts', false);
$driver = RemoteWebDriver::create($host, $desired_capabilities);

NOTE: Above snippets are not intended to be a working example by simply copy-pasting. See example.php for working example.

Changelog

For latest changes see CHANGELOG.md file.

More information

Some how-tos are provided right here in our GitHub wiki.

You may also want to check out the Selenium docs and wiki.

Testing framework integration

To take advantage of automatized testing you may want to integrate php-webdriver to your testing framework. There are some projects already providing this:

Support

We have a great community willing to help you!

  • Via our Facebook Group - If you have questions or are an active contributor consider joining our facebook group and contribute to communal discussion and support
  • Via StackOverflow - You can also ask a question or find many already answered question on StackOverflow
  • Via GitHub - Another option if you have a question (or bug report) is to submit it here as an new issue

Contributing

We love to have your help to make php-webdriver better. See CONTRIBUTING.md for more information about contributing and developing php-webdriver.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.