highscore/browser

一个带有额外实用工具的 chromedriver / laravel dusk 扩展

0.3.4 2020-03-09 08:20 UTC

This package is auto-updated.

Last update: 2024-09-13 15:45:12 UTC


README

此包为laravel dusk浏览器添加了几个方法。还通过建造者模式轻松实例化新的浏览器。

安装

composer require highscore/browser

使用

<?php
use Laravel\Dusk\Browser;

$browser = Browser::configure()
    ->headless()
    ->singleProcess()
    ->host('http://127.0.0.1')
    ->port(9515)
    ->enableRequestLog()
    ->storeScreenshotsAt(storage_path('app/'))
    ->size(1280, 720)
    ->agent('MyCustomAgent 1.0')
    ->proxy('http://proxyurl:9510')
    ->allowDownloadsTo('/tmp')
    ->grantAllPermisions('http://www.google.com')
    ->lang('es')
    ->make();

dump($browser->visit('http://www.google.com')
    ->javascript('return document.title'));


$browser
    ->waitDocumentLoad()
    ->waitFontLoad()
    ->waitForVisible('//img')
    ->waitForClickable('button')
    ->transparentScreenshot('transparent-screenshot');

dump($browser->getNetworkEvents());
dump($browser->html());

运行测试

在127.0.0.1:9515上启动chromedriver并运行phpunit