Coder Social home page Coder Social logo

selenium-handler's Introduction

Selenium Handler

Download, Start & Stop Selenium Server with PHP >= 5.4 as a kind of a client or by command line.

Build Status Scrutinizer Code Quality Dependency Status

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License

This package was written to avoid downloading selenium by hand and to avoid those complex commands to make selenium to start. It also allows you to use it with-in your own package.

Installation

With Composer:

  composer require --dev fonsecas72/selenium-handler

Usage

In your application

You can create a downloader, a starter, a stopper and a watcher. E.g. to create a starter:

$seleniumStarterOptions = new SeleniumStartOptions();
$process = new Process('');
$exeFinder = new ExecutableFinder();
$waiter = new ResponseWaitter(new Client());
$starter = new SeleniumStarter($seleniumStarterOptions, $process, $waiter, $exeFinder);

Then you can call:

$starter->start();

And it will just work.

Of course, you can also change de default settings. This is done by calling options classes that each one if this has. E.g. to change a setting for the starter:

// timeout is changed in the "waitter" class:
$starter->getResponseWaitter()->setTimeout($input->getOption('timeout'));
// to set a specific selenium location you do:
$starterOptions = $starter->getStartOptions();
$starterOptions->setSeleniumJarLocation($input->getOption('selenium-location'));
// to enable xvfb:
$starterOptions->enabledXvfb();

You can also create a "handler" that will allow you to start, stop, download, etc. through one single class.

$this->handler = new SeleniumHandler($starter, $stopper, $downloader, $logWatcher);

see the tests and the built-in commands for more examples, or open an issue

Built-in commands

get selenium

(it will download to current directory by default)

bin/selenium get

You can set the destination directory with

bin/selenium get -d someDir/

You can set the selenium version with

bin/selenium get -s 2.44

start selenium

bin/selenium start

You can give the selenium location with

bin/selenium start --selenium-location /someDir/selenium-server-standalone.jar

Optionally, you may choose whether or not you want to use xvfb

bin/selenium start --xvfb

You can throw selenium options too. For example: You can set the firefox profile to use:

bin/selenium start --selextra firefox-profile=/someDir/toFirefoxProfile

You can also set how much you are willing to wait for selenium to start (in seconds)

bin/selenium start --timeout 60

stop selenium

bin/selenium stop
Tips & Tricks

You can also tail the selenium log after start with follow option:

bin/selenium start --follow

You can even track a specific log level

bin/selenium start --follow ERROR

This can be specially useful if you start selenium in the background before running tests.

bin/selenium start --follow ERROR &

Then if some error happens you will see it in your test log / output.

selenium-handler's People

Contributors

fonsecas72 avatar scrutinizer-auto-fixer avatar dmartinhorodrigues avatar capitaocuecas avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

capitaocuecas

selenium-handler's Issues

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.