Skip to content

Configure screenshots_dir in code, expose savedScreenshots #148

Open
@tacman

Description

@tacman

I want to use this awesome library to navigate my site and save screenshots, not necessarily as part of a functional test, but just a regular app.

final class AppScreenshotsCommand extends InvokableServiceCommand
{
    use PantherTestCaseTrait;
    use HasBrowser;

    public function __invoke(
        IO $io,
    ): void {
        $browser = $this->pantherBrowser(['screenshot_dir' => './screenshots']);
        $browser->visit('/')
            ->wait(4000) // wait for css??
            ->takeScreenshot('homepage.jpg');
        dd($browser->getSavedScreenshots());

How can I set the screenshot_dir in my console command? The above does not work, $options is different in that call.

Also, to get the screenshots at the end, I needed to add a getter to the PantherBrowser.php, would you accept a PR for that?

    public function getSavedScreenshots(): array
    {
        return $this->savedScreenshots;
    }

I am trying to use this to solve the problem of creating screenshots requiring authenticated users, e.g.

Spomky-Labs/pwa-bundle#134

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions