Programmatically navigate/test the web.
You may install this package using composer.
$ composer require bhittani/web-browser
$ vendor/bin/install-chrome-driver
$ vendor/bin/install-phantomjs-driver
This package conveniently wraps laravel/dusk.
First ensure you have installed the chrome driver.
<?php
use Bhittani\WebBrowser\Chrome;
$browser = new Chrome;
First ensure you have installed the phantomjs driver.
<?php
use Bhittani\WebBrowser\Phantomjs;
$browser = new Phantomjs;
All browser instances extend Laravel\Dusk\Browser
, hence, the same API applies.
<?php
$browser->visit('https://example.com')->assertSee('Example');
We can also make assertions and capture failures within a testing environment.
<?php
use Bhittani\WebBrowser\Browser;
use Bhittani\WebBrowser\Phantomjs;
use Bhittani\WebBrowser\Testing;
Testing::bootstrap(); // Required for purging failed assertions.
Browser::test(function ($browser1, $browser2/*, ... */) {
$browser1->visit('https://example.com')->assertSee('Example');
$browser2->visit('https://example.net')->assertSee('Example');
});
Phantomjs::test(/*...*/);
Testing::tearDown(); // Required for closing all browsers.
The above test callback will capture any failed assertions by taking a screenshot, save the console log and the source of a web page that caused the failure.
A TestCase
class and a TestTrait
trait under the Bhittani\WebBrowser
namespace is included for making it easy to write your browser tests using PHPUnit
.
Please see CHANGELOG for more information on what has changed.
$ git clone https://github.com/kamalkhan/web-browser
$ cd web-browser
$ composer install
$ composer install-drivers
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email shout@bhittani.com
instead of using the issue tracker.
The MIT License (MIT). Please see the License File for more information.