PHP Selenium client
Selenium is a great tool for testing. This package gives you a boilerplate setup to automate UI testing tasks you'd do manually otherwise.
For example: you can make a scenario to test the flow of a form in one of your projects, without having to worry about setting up Selenium itself. This package uses Chrome by default, but you're able to override it with whatever driver you want.
Support us
Learn how to create a package like this one, by watching our premium video course:
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
git clone git@github.com:spatie/selenium-client.git
Usage
You can add your own scenarios in the Scenarios folder.
Next, you'll need to start the Selenium server like so:
php client.php serve
Next you can run your scenarios like so:
php client.php execute dummy [--wait]
Adding the --wait option will keep the browser open until you manually stop it.
Making scenarios
Scenario classes should extend Spatie\Selenium\Scenario. There are a few helper methods provided like $this->element($selector) and $this->click($selector); but you can also directly access the Selenium driver via $this->driver.
For more information about the Selenium driver, please visit this repository.
A simple scenario can look like this.
class MyScenario extends Scenario
{
public function __construct()
{
// The website to visit.
parent::__construct('https://mywebsite.com.test');
}
public function run()
{
// Go to a page
$this->get('/contact');
$this->element('input[name=name]')->sendKeys('Brent');
$this->element('input[name=email]')->sendKeys('brent@spatie.be');
$this->element('input[name=message']->sendKeys('Test');
$this->submit('form#contact');
}
}
Scenarios can be run with the execute command, in this case you'd run execute my.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.
Postcardware
You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.
Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.
We publish all received postcards on our company website.
Credits
License
The MIT License (MIT). Please see License File for more information.