1

I have been unable to resize the Selenium WebDriver in my protractor/cucumber testing.

These are some of the commands that I have tried.

webdriver.WebDriver.Window().setSize(width, height);
webdriver.WebDriver.Window().setSize(width, height);
webdriver.WebDriver.Window.setSize(width, height);
webdriver.WebDriver.Window.prototype.setSize(width, height);

From here

browser.driver.manage().window().setSize(width, height);

How to set default browser window size in Protractor/WebdriverJS

And:

browser.driver.manage().window().maximize();
webdriver.WebDriver.Window.prototype.maximize();
webdriver.WebDriver.Window.maximize();
browser.driver.manage().window().maximize();

This article, for example, was no help as I don't know where the imports come from.

I have had no luck understanding the root of this issue as they all return promises and I am not sure how to debug them.

I am using protractor version 2.0.0

Thank you for any help!

Community
  • 1
  • 1
JasoonS
  • 1,432
  • 3
  • 13
  • 26

1 Answers1

1

browser.manage().window().setSize(width, height); works for me. Notice that I'm not trying to call to driver as you do in your examples. My full step def looks like this:

this.Given(/^I (?:have|change to|resize to|rotate to) a (\d+)x(\d+) screen size$/, function(width, height, callback) {
  browser.manage().window().setSize(parseInt(width, 10), parseInt(height, 10));
  return callback();
});

You can find that and other examples in the CukeFarm library. Full disclosure: I helped build that library.

Nathan Thompson
  • 2,354
  • 1
  • 23
  • 28