Coder Social home page Coder Social logo

webdriver-manager's Introduction

WebDriver Manager

Build Status Scrutinizer Code Quality

The perfect companion for projects with functional tests. Heavily inspired by the webdriver-manager that ships with protractor. WebDriver Manager allows you to keep Selenium Server binaries up to date. It also provides a packaged solution for easily starting Selenium Server.

In addition to an easy to use command line application, WebDriver Manager provides a library for managing Selenium binaries in your own apps and tools.

Installation

WebDriver Manager is meant to be a drop in installation for any project using Selenium WebDriver for functional tests.

$ composer require --dev peridot-php/webdriver-manager

Once installed, you can operate Selenium Server from the comfort of your project:

$ vendor/bin/manager start

Usage

WebDriver Manager Usage

clean

Remove all installed binaries.

WebDriver clean command

status

List all available binaries and their installed status. Status shows if the binary is installed, out of date, or missing.

WebDriver status command

update

The update command downloads current binaries and deletes old ones.

WebDriver update command

start

Starts Selnium Server with all drivers managed by WebDriver Manager. The start command will run an update at start to make sure drivers are available and up to date.

WebDriver start command

Library Usage

WebDriver manager exposes a really simple interface that makes it easy to leverage in your own applications and tools:

use Peridot\WebDriverManager\Manager;

$manager = new Manager();

$manager->update(); //update all binaries
$manager->update('selenium'); //only update selenium

$manager->clean(); //remove installed binaries

$manager->startInForeground(); //start selenium in the foreground on port 4444
$manager->startInForeground(9999); //start selenium in the foreground on port 9999
$manager->startInBackground(); //start selenium in the background on port 4444
$manager->startInBackground(9999); //start in the background on port 9999 

$path = $manager->getInstallPath(); //where binaries are installed
$manager->setInstallPath(__DIR__); //set the path to install binaries

$manager->addBinary(new MyCustomDriver()); //add a binary to manage
$manager->removeBinary('chromdedriver'); //remove a managed binary
$binaries = $manager->getBinaries(); //get a collection of managed binaries

A note on starting Selenium in the background

WebDriver Manager does not block when starting a background process. This makes it difficult to see if Selenium encountered any errors (perhaps a corrupt binary?). The SeleniumProcess class provides a method for checking the status of the process. If you want to check that Selenium Server started in the background ok, you might try something like this:

$process = $manager->startInBackground();
usleep(250000); //give Selenium a quarter of a second to validate input
if (! $process->isRunning()) {
	//Selenium encountered an error
	print $process->getError();
	$process->close();
    return;
}

//do rad Selenium things

For more information, see the API docs;

Examples

The API has been used to create a custom Behat listener capable of starting the server before Mink tests are run. This tool is included as part of a demo project known as behavior driven todos.

Running Tests

WebDriver Manager's tests were written using the Peridot test framework.

Unit tests can be run like so:

$ vendor/bin/peridot

And integration tests can be run like this:

$ vendor/bin/peridot --grep *.it.php

Contributing

Please feel free to open issues or pull requests.

webdriver-manager's People

Contributors

austinsmorris avatar brianium avatar ezzatron avatar formigone avatar jails avatar marcandreuf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.