As mentioned in the below blog, we can modify screen resolution during selenium test runs. http://blog.testingbot.com/2013/03/15/screen-resolution-option-now-available-for-all-selenium-tests
Tried the below code(as mentioned in "https://saucelabs.com/docs/additional-config"), but not setting the specified resolution. Is this still not available for Selenium?
DesiredCapabilities dc=new DesiredCapabilities();
dc.setCapability("screen-resolution","1280x1024");
void setSize() – This method is used to set the size of the current browser. Dimension getSize() – This method is used to get the size of the browser in height and width. It returns the dimension of the browser. Point setPosition() – This method is used to set the position of the current browser.
Sauce Labs users can explicitly specify the desired resolution. In order to do so, you simply need to add an additional entry to your DesiredCapabilies object, called "screenResolution".
We can resize the browser window in Selenium webdriver. We can configure the size of the browser with the help of the set_window_size method in Python. The dimensions of the window size are passed as parameters to this method. Again, to get the size of the browser, we can use the method get_window_size.
Sauce Labs != Selenium
Sauce labs use that capability to provision you a VM with the desired resolution, it's not a capability that Selenium itself knows about.
Selenium is not capable of modifying your desktop resolution!
If you want to modify your browser size in Selenium so that it matches a specific resolution you can do a:
driver.manage().window().setSize(new Dimension(1024, 768))
The above is not supported with Opera driver, so instead you would need to do:
DesiredCapabilities capabilities = DesiredCapabilities.opera()
capabilities.setCapability("opera.arguments", "-screenwidth 1024 -screenheight 768")
While setting the browser size is not the same as setting the screen resolution, it should for all intents and purposes meet your requirements.
Selenium is a browser automation framework, its job is to drive a browser, not to automate your system. I don't think that a functionality such as setting a screen resolution will ever be implemented in Selenium. Setting resolution has simply nothing to do with browser automation.
I am not sure why do you want to change the resolution... How about just changing the size of your browser window? That's something you could do if you are testing responsive-designed pages.
driver.manage().window().setSize(new Dimension(800, 600));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With