Reputation: 101
As explained elsewhere (Take a screenshot with Selenium WebDriver), you can take screenshots easily with PHPUnit using the Selenium Webdriver class PHPUnit_Extensions_Selenium2TestCase .
However, I cannot find a way to set the screen size of the generated screenshots. By default, their width seems to be limited to 1000 pixels.
BTW: the above mentioned Stackoverflow thread is closed. So I cannot post my question there.
Upvotes: 2
Views: 4534
Reputation: 101
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.
Upvotes: 3