Skip to content
Advertisement

Panther Chrome WebDriver : Full screen?

In my functional test of my symfony 4 application, i use the Chrome Webdriver with PANTHER_NO_HEADLESS=1 to see what happen.

My problem is : Chrome browser starting with Debug Tool (F12) and not in full screen. This is a problem because i want to test elements that appears only on full screen.

My test :

public function testMyTest()
{
    $client = Client::createChromeClient();
    $crawler = $client->request('GET', 'http://example.com/form');
    $form = $crawler->selectButton('valider')->form([
        'formField' => 'value'
    ]);

    $client->submit($form)

    // Some assertions here
}

Command :

$export PANTHER_NO_HEADLESS=1

Then

phpunit -c phpunitFunctional.xml --filter="testMyTest" path/to/FileTest.php

How can i start with full screen and without debug tool ?

Advertisement

Answer

I’ve finally found a solution. I write it in case of someone has the same problem.

public function testMyTest()
{
    $client = Client::createChromeClient();
    $crawler = $client->request('GET', 'http://example.com/form');
    $client->manage()->window()->maximize();

    $form = $crawler->selectButton('valider')->form([
        'formField' => 'value'
    ]);

    $client->submit($form)

    // Some assertions here
}
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement