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");
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.