PHPackages                             lmc/steward - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. lmc/steward

ActiveLibrary[Testing &amp; Quality](/categories/testing)

lmc/steward
===========

Steward - makes Selenium WebDriver + PHPUnit testing easy and robust

3.1.0(2y ago)222163.1k—5.4%40[20 issues](https://github.com/lmc-eu/steward/issues)1MITPHPPHP ^7.3 || ^8.0

Since Apr 24Pushed 1y ago16 watchersCompare

[ Source](https://github.com/lmc-eu/steward)[ Packagist](https://packagist.org/packages/lmc/steward)[ RSS](/packages/lmc-steward/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (27)Versions (34)Used By (1)

Steward: easy and robust testing with Selenium WebDriver + PHPUnit
==================================================================

[](#steward-easy-and-robust-testing-with-selenium-webdriver--phpunit)

[![Latest Stable Version](https://camo.githubusercontent.com/788096aacf1ea5630bcdd4a57760ce2a3ec0cc438cfab58f957e64f312af07a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6d632f737465776172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lmc/steward)[![GitHub Actions Build Status](https://camo.githubusercontent.com/1d10c412ff056376389f39acbdae26ea6d66ed0587536123a08bca07f7f90aa7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6d632d65752f737465776172642f74657374732e79616d6c3f7374796c653d666c61742d737175617265266c6162656c3d476974487562253230416374696f6e732532306275696c64)](https://github.com/lmc-eu/steward/actions)[![AppVeyor Build Status](https://camo.githubusercontent.com/dd881578230ecb5b543691adf755d08c7ccb7cd74f0dfa385dd20de0a8c109cc/68747470733a2f2f696d672e736869656c64732e696f2f6170707665796f722f63692f6c6d632d65752f737465776172642f6d61696e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d4170705665796f72)](https://ci.appveyor.com/project/lmc-eu/steward)[![Coverage Status](https://camo.githubusercontent.com/071fb57e6ec914f93b343cc064cfb8c1ad9f3014b4a7d3ea53489872b52231f5/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c6d632d65752f737465776172642f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/lmc-eu/steward?branch=main)[![Total Downloads](https://camo.githubusercontent.com/d660c4af7270ff0ec9180c200e0f5806fcdb70f397737793637cfec914d5d868/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6d632f737465776172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lmc/steward)

Steward is a set of libraries made to simplify writing and running robust functional system tests in [PHPUnit](https://phpunit.de/) using [Selenium WebDriver](https://www.selenium.dev/).

What's great about Steward?
---------------------------

[](#whats-great-about-steward)

- It allows you to start writing complex test cases in a minute.
- It performs a lot of work for you:
    - downloads and installs Selenium server with one command
    - sets-up browser of your choice
    - automatically takes a screenshot on failed assertions
    - produces test results in JUnit format (easily processable, for example, by Jenkins and other tools)
    - and more...
- Tests are run in parallel, so the only bottleneck is the number of Selenium nodes you start simultaneously.
- Simple syntax sugar layer on top of default [WebDriver commands](https://github.com/php-webdriver/php-webdriver/wiki/Example-command-reference) helps shorten your tests and improve readability.
- If you already use PHP, you don't have to learn a new language to write functional tests. Moreover, if you are familiar with unit tests and PHPUnit, you know it all.
- Allows you to plan test dependencies.
    - For example, if you need to wait 2 minutes until some event gets through your message queue before testing the result? No problem! The order of tests is optimized to minimize the total execution time.
- Status of tests can be clearly watched during test execution, so you will easily know how many tests have finished and what their results are.
- You can extend Steward easily by registering custom events to EventDispatcher.
    - For example if you can add custom configuration options or change parameters passed to child PHPUnit processes.
- Cloud services like [Sauce Labs](https://saucelabs.com/), [BrowserStack](https://www.browserstack.com/) or [TestingBot](https://testingbot.com/) are fully integrated giving you a chance to run tests with less setup and without your own infrastructure.
- Steward is field tested - we use it daily in [our company](https://www.lmc.eu/en/) to maintain the quality of our products thanks to hundreds of test-cases. The library itself is also extensively covered by unit tests.
- Steward is built on solid foundations: [WebDriver](https://www.w3.org/TR/webdriver/) is W3C draft standard for browser automation, [php-webdriver](https://github.com/php-webdriver/php-webdriver) is the most used and developed Selenium language binding for PHP, [PHPUnit](https://phpunit.de/) is a well known and widely used testing framework, and [Symfony Console](https://symfony.com/doc/current/components/console.html) is industry standard for PHP CLI applications.

Example usage
-------------

[](#example-usage)

To see how to use and extend Steward, have a look at our [example project](https://github.com/lmc-eu/steward-example).

Changelog
---------

[](#changelog)

For the latest changes see the [CHANGELOG.md](./CHANGELOG.md) file. We follow [Semantic Versioning](https://semver.org/).

Getting started
---------------

[](#getting-started)

### 1. Install Steward

[](#1-install-steward)

For most cases we recommend having functional tests in the same repository as your application but in a separate folder. We suggest putting them in a `selenium-tests/` directory.

**In this directory**, simply install Steward with the following command:

```
$ composer require lmc/steward
```

**Note:** you will need to have [Composer](https://getcomposer.org/) installed to do this.

### 2. Download Selenium Server and browser drivers

[](#2-download-selenium-server-and-browser-drivers)

The following step only applies if you want to download and run Selenium Standalone Server with the test browser locally right on your computer. Another possibility is to [start Selenium Server and test browser inside a Docker container](https://github.com/lmc-eu/steward/wiki/Selenium-server-&-browser-drivers#option-2-start-selenium-server--browser-inside-docker-).

#### Get Selenium Standalone Server

[](#get-selenium-standalone-server)

You need to download Selenium server so it can execute commands in the specified browser. In the root directory of your tests (e.g. `selenium-tests/`) simply run:

```
$ ./vendor/bin/steward install
```

This will check for the latest version of Selenium Standalone Server and download it for you (the jar file will be placed into the `./vendor/bin` directory).

You may want to run this command as part of your CI server build, then simply use the `--no-interaction` option to download Selenium without any interaction and print the absolute path to the jar file as the sole output.

#### Download browser drivers

[](#download-browser-drivers)

If it is not already installed on your system, you will need to download Selenium driver for the browser(s) you want to use for the tests. See [Selenium server &amp; browser drivers](https://github.com/lmc-eu/steward/wiki/Selenium-server-&-browser-drivers#2-install-browser-driver)in our wiki for more information.

### 3. Write the first test

[](#3-write-the-first-test)

To provide you with Steward functionality, your tests have to extend the `Lmc\Steward\Test\AbstractTestCase` class.

You must also configure [PSR-4 autoloading](https://www.php-fig.org/psr/psr-4/) so that your tests could be found by Steward. It is as easy as adding the following to your `composer.json` file:

```
    "autoload": {
        "psr-4": {
            "My\\": "tests/"
        }
    }
```

Don't forget to create the `selenium-tests/tests/` directory and to run `composer dump-autoload` afterward.

For the test itself, place it in the `selenium-tests/tests/` directory:

```
