apsonex/laravel-dusk-screenrecordings
Composer 安装命令:
composer require apsonex/laravel-dusk-screenrecordings
包简介
A package to have screen recordings of Dusk tests
README 文档
README
Laravel Dusk Screenrecording is a package, that was created by and maintained by Sander van Kasteel that enables you to do screenrecording of your Dusk tests.
<INSERT_EXAMPLE>
Usage
Warning: Currently only Chrome is supported
Requires PHP 7.4+
Requires Laravel 7 (or higher)
- First install the pacakge
composer require --dev sandervankasteel/laravel-dusk-screenrecordings
- Publish the configuration
php artisan vendor:publish
- Modify your
tests/DuskTestcase.phpto have screen recordings work.
Example implmentation
protected function driver() { $options = (new ChromeOptions) ->setExperimentalOption("prefs", [ "download.default_directory" => $this->downloadDir ]) ->addArguments(collect([ '--window-size=1920,1080', ])->unless($this->hasHeadlessDisabled(), function ($items) { return $items->merge([ '--disable-gpu', '--headless', ]); })->merge( $this->getChromeArgs() )->all()); return RemoteWebDriver::create( $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( ChromeOptions::CAPABILITY, $options ) ); }
The most important parts are the
$this->getChromeArgs()
and the
->setExperimentalOption("prefs", [ "download.default_directory" => $this->downloadDir ])
Firstly, we need to get a specific set of arguments, so that Chrome will allow us to record from an non-HTTPS source and automatically select the source from which to record from.
Lastly, we need to set download.default_directory to a known directory, so we know from which directory we need to move our
recordings from.
- Add the
WithScreenRecordingsto yourtests/DuskTestCase.php, so we will actually record and store the recordings.
use Sandervankasteel\LaravelDuskScreenrecordings\WithScreenRecordings; abstract class DuskTestCase extends BaseTestCase { use CreatesApplication, WithScreenRecordings; // Rest of your DuskTestCase }
- Run
php artisan duskto see it in action 🥳 🚀
How it works
This package works by loading a browser plugin, which in turns creates a new (pinned) tab in the browser, then it initializes the screenrecording and then executes the test as usual.
Once the tests are finished, based on the configuration it will 'download' the screenrecording from the tab created by the browser extension.
TODO
- Add Firefox support
- Fix
--auto-select-desktop-capture-sourceargument under Linux - Ideal case scenario: enable window recording (instead of the full desktop).
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-09