All Projects → php-webdriver → Php Webdriver

php-webdriver / Php Webdriver

Licence: mit
PHP client for Selenium/WebDriver protocol. Previously facebook/php-webdriver

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to Php Webdriver

atata-kendoui
A set of Atata components for Kendo UI
Stars: ✭ 17 (-99.62%)
Mutual labels:  webdriver, selenium, selenium-webdriver
Atata
C#/.NET test automation framework for web
Stars: ✭ 362 (-91.91%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Thirtyfour
Selenium WebDriver client for Rust, for automated testing of websites
Stars: ✭ 191 (-95.73%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Java.webdriver
Browser test automation using Selenium WebDriver in Java
Stars: ✭ 135 (-96.98%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Selenium Maven Template
A maven template for Selenium that will let you check out and go.
Stars: ✭ 403 (-91%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Webium
Webium is a Page Object pattern implementation library for Python (http://martinfowler.com/bliki/PageObject.html). It allows you to extend WebElement class to your custom controls like Link, Button and group them as pages.
Stars: ✭ 144 (-96.78%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Golem
A complete test automation tool
Stars: ✭ 441 (-90.15%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Webdriverextensions
Make your WebDriver based Selenium tests more readable, reusability and maintainable by using WebDriver Extensions!
Stars: ✭ 89 (-98.01%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Htmlelements
Html Elements is a Java framework providing easy-to-use way of interaction with web-page elements in web-page tests.
Stars: ✭ 258 (-94.24%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (-94.82%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Nightwatch
End-to-end testing framework written in Node.js and using the Webdriver API
Stars: ✭ 10,912 (+143.73%)
Mutual labels:  selenium, webdriver, w3c-webdriver
spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-99.46%)
Mutual labels:  webdriver, selenium, selenium-webdriver
Marionette
Selenium alternative for Crystal. Browser manipulation without the Java overhead.
Stars: ✭ 119 (-97.34%)
Mutual labels:  selenium, webdriver, selenium-webdriver
page-modeller
⚙️ Browser DevTools extension for modelling web pages for automation.
Stars: ✭ 66 (-98.53%)
Mutual labels:  webdriver, selenium, selenium-webdriver
Csharp.webdriver
Browser test automation using Selenium WebDriver in C#
Stars: ✭ 115 (-97.43%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Panther
A browser testing and web crawling library for PHP and Symfony
Stars: ✭ 2,480 (-44.61%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Java.appium
Mobile test automation using Appium in Java
Stars: ✭ 59 (-98.68%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Cabbie
WebDriver for the masses
Stars: ✭ 70 (-98.44%)
Mutual labels:  selenium, webdriver, selenium-webdriver
Steward
PHP libraries that makes Selenium WebDriver + PHPUnit functional testing easy and robust
Stars: ✭ 215 (-95.2%)
Mutual labels:  selenium, webdriver, selenium-webdriver
google-meet-bot
Bot for scheduling and entering google meet sessions automatically
Stars: ✭ 33 (-99.26%)
Mutual labels:  webdriver, selenium, selenium-webdriver

php-webdriver – Selenium WebDriver bindings for PHP

Latest stable version GitHub Actions build status SauceLabs test status Total downloads

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, 3.x and 4.x.

The library supports JsonWireProtocol and also implements experimental support of W3C WebDriver. The W3C WebDriver support is not yet full-featured, however it should allow to control Firefox via Geckodriver and new versions of Chrome and Chromedriver with just a slight limitations.

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

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 php-webdriver/webdriver

Upgrade from version <1.8.0

Starting from version 1.8.0, the project has been renamed from facebook/php-webdriver to php-webdriver/webdriver.

In order to receive the new version and future updates, you need to rename it in your composer.json:

"require": {
-    "facebook/webdriver": "(version you use)",
+    "php-webdriver/webdriver": "(version you use)",
}

and run composer update.

Getting started

1. Start server (aka. remote end)

To control a browser, you need to start a remote end (server), which will listen to the commands sent from this library and will execute them in the respective browser.

This could be Selenium standalone server, but for local development, you can send them directly to so-called "browser driver" like Chromedriver or Geckodriver.

a) Chromedriver

📙 Below you will find a simple example. Make sure to read our wiki for more information on Chrome/Chromedriver.

Install the latest Chrome and Chromedriver. Make sure to have a compatible version of Chromedriver and Chrome!

Run chromedriver binary, you can pass port argument, so that it listens on port 4444:

chromedriver --port=4444

b) Geckodriver

📙 Below you will find a simple example. Make sure to read our wiki for more information on Firefox/Geckodriver.

Install the latest Firefox and Geckodriver. Make sure to have a compatible version of Geckodriver and Firefox!

Run geckodriver binary (it start to listen on port 4444 by default):

geckodriver

c) Selenium standalone server

Selenium server can be useful when you need to execute multiple tests at once, when you run tests in several different browsers (like on your CI server), or when you need to distribute tests amongst several machines in grid mode (where one Selenium server acts as a hub, and others connect to it as nodes).

Selenium server then act like a proxy and takes care of distributing commands to the respective nodes.

The latest version can be found on the Selenium download page.

📙 You can find further Selenium server information in our wiki.

d) Docker

Selenium server could also be started inside Docker container - see docker-selenium project.

2. Create a Browser Session

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

For example:

// Chromedriver (if started using --port=4444 as above)
$serverUrl = 'http://localhost:4444';
// Geckodriver
$serverUrl = 'http://localhost:4444';
// selenium-server-standalone-#.jar (version 2.x or 3.x)
$serverUrl = 'http://localhost:4444/wd/hub';
// selenium-server-standalone-#.jar (version 4.x)
$serverUrl = 'http://localhost:4444';

Now you can start browser of your choice:

use Facebook\WebDriver\Remote\RemoteWebDriver;

// Chrome
$driver = RemoteWebDriver::create($serverUrl, DesiredCapabilities::chrome());
// Firefox
$driver = RemoteWebDriver::create($serverUrl, DesiredCapabilities::firefox());
// Microsoft Edge
$driver = RemoteWebDriver::create($serverUrl, DesiredCapabilities::microsoftEdge());

3. Customize Desired Capabilities

Desired capabilities define properties of the browser you are about to start.

They can be customized:

use Facebook\WebDriver\Firefox\FirefoxOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;

$desiredCapabilities = DesiredCapabilities::firefox();

// Disable accepting SSL certificates
$desiredCapabilities->setCapability('acceptSslCerts', false);

// Add arguments via FirefoxOptions to start headless firefox
$firefoxOptions = new FirefoxOptions();
$firefoxOptions->addArguments(['-headless']);
$desiredCapabilities->setCapability(FirefoxOptions::CAPABILITY, $firefoxOptions);

$driver = RemoteWebDriver::create($serverUrl, $desiredCapabilities);

Capabilities can also be used to 📙 configure a proxy server which the browser should use.

To configure browser-specific capabilities, you may use 📙 ChromeOptions or 📙 FirefoxOptions.

4. Control your browser

// Go to URL
$driver->get('https://en.wikipedia.org/wiki/Selenium_(software)');

// Find search element by its id, write 'PHP' inside and submit
$driver->findElement(WebDriverBy::id('searchInput')) // find search input element
    ->sendKeys('PHP') // fill the search box
    ->submit(); // submit the whole form

// Find element of 'History' item in menu by its css selector
$historyButton = $driver->findElement(
    WebDriverBy::cssSelector('#ca-history a')
);
// Read text of the element and print it to output
echo 'About to click to a button with text: ' . $historyButton->getText();

// Click the element to navigate to revision history page
$historyButton->click();

// Make sure to always call quit() at the end to terminate the browser session
$driver->quit();

See example.php for full example scenario. Visit our GitHub wiki for 📙 php-webdriver command reference and further examples.

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

Changelog

For latest changes see CHANGELOG.md file.

More information

Some basic usage example is provided in example.php file.

How-tos are provided right here in 📙 our GitHub wiki.

If you don't use IDE, you may use API documentation of php-webdriver.

You may also want to check out the Selenium project 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!

Do you have a question, idea or some general feedback? Visit our Discussions page. (Alternatively, you can look for many answered questions also on StackOverflow).

🐛 Something isn't working, and you want to report a bug? Submit it here as a new issue.

📙 Looking for a how-to or reference documentation? See our wiki.

Contributing ❤️

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

Php-webdriver is community project - if you want to join the effort with maintaining and developing this library, the best is to look on issues marked with "help wanted" label. Let us know in the issue comments if you want to contribute and if you want any guidance, and we will be delighted to help you to prepare your pull request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].