bhittani/web-browser
Composer 安装命令:
composer require --dev bhittani/web-browser
包简介
A convenience wrapper around laravel/dusk
README 文档
README
Programmatically navigate/test the web.
Requirements
- PHP >= 7.2
Install
You may install this package using composer.
$ composer require bhittani/web-browser
Install chrome driver
$ vendor/bin/install-chrome-driver
Install phantomjs driver
$ vendor/bin/install-phantomjs-driver
Usage
This package conveniently wraps laravel/dusk.
Chrome
First ensure you have installed the chrome driver.
<?php use Bhittani\WebBrowser\Chrome; $browser = new Chrome;
Phantomjs
First ensure you have installed the phantomjs driver.
<?php use Bhittani\WebBrowser\Phantomjs; $browser = new Phantomjs;
API
All browser instances extend Laravel\Dusk\Browser, hence, the same API applies.
Example
<?php $browser->visit('https://example.com')->assertSee('Example');
Testing
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.
PHPUnit
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.
Changelog
Please see CHANGELOG for more information on what has changed.
Testing
$ git clone https://github.com/kamalkhan/web-browser $ cd web-browser $ composer install $ composer install-drivers $ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email shout@bhittani.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see the License File for more information.
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-11