Screenshots with Selenium Webdriver: How can I set the window size? Screenshots with Selenium Webdriver: How can I set the window size? selenium selenium

Screenshots with Selenium Webdriver: How can I set the window size?


Have you tried to resize your browser window? I found interesting post about it here. Some code snippet from there:

    $this->currentWindow()->size(array(  'width' => 800,  'height' => 600,));


Thank you very much! This solves my problem. I post my code to provide a more complete example:

You can get any window with $this->currentWindow()and then call the "closure method" size() on it. I put that into my setupPage() method.

class DrupalWebtestBase extends \PHPUnit_Extensions_Selenium2TestCase{    /* ... */    public function setUpPage()    {               parent::setUpPage();        if( $this->width && $this->height )        {                // main window is named ''              $this->window('');            // get window object            $window = $this->currentWindow();            // set window size            $window->size( array(                            'width'     => $this->width,                            'height'    => $this->height) );        }    }}

The screenshots taken later on reflect the set window dimensions above.