Last Updated: February 25, 2016
·
3.931K
· sgsabbage

Resizing the PhantomJS window when using Behat/Mink

When using Behat with Mink and PhantomJS (in WebDriver mode), control over the window size can be very important when working with responsive design.

The Mink documentation states that if you use resizeWindow() without filling in the third argument (window name), it will use the current window.

This works for Selenium where calling '/window/size' works on the main window, but not for PhantomJS. Instead, use the window name 'current'.

E.g.

$this->getSession()->resizeWindow(1440, 900, 'current');

3 Responses
Add your response

Nice! Man, I was wondering what was wrong with my seemingly normal implementation. Boy, documentation for this stuff is tough to wade through. Thanks a million!

over 1 year ago ·

Thanks to you, I only lost an hour instead of a day for this stupid issue ! :D

over 1 year ago ·

Thanks.

I now tag Scenarios where this was causing a problem @bigWindow

  /**
   * @BeforeScenario @bigWindow
   */
  public function beforeBigWindow(BeforeScenarioScope $scope) {
    $this->getSession()->resizeWindow(1440, 900, 'current');
  }
}

alternatively, annotating the function @BeforeScenario <at>javascript instead seems to work too, but I was concerned that I'd need to call a parent function - but so far so good (<at> to avoid generated links on this forum!)

over 1 year ago ·