Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Change screen resolution
Learn how to change the screen resolution for your Selenium tests that run on desktop browsers.
As part of responsive web app testing scenarios, you might want to test your application on different screen resolutions.
With the custom resolution capability, you can set a supported screen resolution for a desktop-OS version combination and observe your application behavior.
By default, on BrowserStack, all Selenium tests that run on desktop run on a screen resolution of1920x1080.
Browser window is not maximized upon launch in any Selenium test. Changing the resolution doesnβt maximize the browser. Check out how to maximize and resize the browser window if you want to maximize the browser window upon launch.
If you are using BrowserStack SDK, you can set the following capabilities in the configuration file:
Capability
Description
Expected values
resolution
Set the resolution of your VM before beginning your test
A string. Default resolution is 1920x1080
Supported resolutions: Windows (XP):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080 and 2048x1536
Windows (7):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
Windows (8, 8.1, 10, 11):1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
OS X (Golden Gate, Tahoe, Sequoia, Sonoma, Ventura, Monterey, Big Sur, Catalina, Mojave, and High Sierra):1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080, 2560x1440, 2560x1600, and 3840x2160
OS X (All other versions):1024x768, 1280x960, 1280x1024, 1600x1200, and 1920x1080
You can set the resolution capability as shown in the following example code snippet that sets the value to 1024x768.
Sample screenshots before and after resolution change
In the following sample screenshot, for different resolutions, we ran the sample tests to open www.browserstack.com on Chrome 88 browser running on Windows 10:
Resolution - 1024x768
Resolution - 2048x1536
Maximize window with resolution - 2048x1536
The largest supported screen resolution for Windows machines is 2048x1536. If you run the maximize window steps, then your test with the largest screen resolution for Windows as shown in the following image:
Example code snippets
The following example code snippet shows how the resolution capability can be used to set custom screen resolutions for BrowserStack SDK integration:
```yml
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
platforms:
- os: Windows
osVersion: 11
browserName: Chrome
browserVersion: 103.0
- os: Windows
osVersion: 10
browserName: Firefox
browserVersion: 102.0
- os: OS X
osVersion: Big Sur
browserName: Safari
browserVersion: 14.1
parallelsPerPlatform: 1
browserstackLocal: true
buildName: bstack-demo
buildIdentifier: ${BUILD_NUMBER}
projectName: BrowserStack Sample
testObservability: true
networkLogs: true
consoleLogs: info
resolution: 1024x768
```
You can use either Selenium 4 or Selenium Legacy JSON to to provide a custom resolution.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
The following table provides information about supported screen resolution values for different desktop-OS version combinations.
Capability
Description
Expected values
resolution
Set the resolution of your VM before beginning your test
A string. Default resolution is 1920x1080
Supported resolutions: Windows (XP):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080 and 2048x1536
Windows (7):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
Windows (8, 8.1, 10, 11):1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
OS X (Golden Gate, Tahoe, Sequoia, Sonoma, Ventura, Monterey, Big Sur, Catalina, Mojave, and High Sierra):1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080, 2560x1440, 2560x1600, and 3840x2160
OS X (All other versions):1024x768, 1280x960, 1280x1024, 1600x1200, and 1920x1080
You can set the resolution capability as shown in the following example code snippet that sets the value to 1024x768.
// Change resolution to 1024x768MutableCapabilitiescapabilities=newMutableCapabilities();HashMap<String,Object>browserstackOptions=newHashMap<String,Object>();browserstackOptions.put("resolution","1024x768");// Set the selenium version to 4.0.0.browserstackOptions.put("seleniumVersion","4.0.0");capabilities.setCapability("bstack:options",browserstackOptions);
// Change resolution to 1024x768varcapabilities={'bstack:options':{"resolution":"1024x768",// Set the selenium version to 4.0.0."seleniumVersion":"4.0.0",},}
// Change resolution to 1024x768// For Chrome browserChromeOptionscapabilities=newChromeOptions();capabilities.BrowserVersion="95.0";Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("resolution","1024x768");// Set the selenium version to 4.0.0.browserstackOptions.Add("seleniumVersion","4.0.0");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);// For Edge browserEdgeOptionscapabilities=newEdgeOptions();capabilities.BrowserVersion="95.0";Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("resolution","1024x768");// Set the selenium version to 4.0.0.browserstackOptions.Add("seleniumVersion","4.0.0");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);// For IE browserInternetExplorerOptionscapabilities=newInternetExplorerOptions();capabilities.BrowserVersion="11.0";Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("resolution","1024x768");// Set the selenium version to 4.0.0.browserstackOptions.Add("seleniumVersion","4.0.0");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);// For Firefox browserFirefoxOptionscapabilities=newFirefoxOptions();capabilities.BrowserVersion="95.0";Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("resolution","1024x768");// Set the selenium version to 4.0.0.browserstackOptions.Add("seleniumVersion","4.0.0");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);
# Change resolution to 1024x768$caps=array('bstack:options'=>array("resolution"=>"1024x768",//Set the selenium version to 4.0.0."seleniumVersion"=>"4.0.0",),)
# Change resolution to 1024x768
desired_cap={'bstack:options':{"resolution":"1024x768",# Set the selenium version to 4.0.0.
"seleniumVersion":"4.0.0",},}
# Change resolution to 1024x768capabilities={'bstack:options'=>{"resolution"=>"1024x768",#Set the selenium version to 4.0.0."seleniumVersion"=>"4.0.0",},}
The following table provides information about supported screen resolution values for different desktop-OS version combinations.
Capability
Description
Expected values
resolution
Set the resolution of your VM before beginning your test
A string. Default resolution is 1920x1080
Supported resolutions: Windows (XP):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080 and 2048x1536
Windows (7):800x600, 1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
Windows (8, 8.1, 10, 11):1024x768, 1280x800, 1280x1024, 1366x768, 1440x900, 1680x1050, 1600x1200, 1920x1200, 1920x1080, 2048x1536, 2560x1600, 2800x2100, and 3840x2160
OS X (Golden Gate, Tahoe, Sequoia, Sonoma, Ventura, Monterey, Big Sur, Catalina, Mojave, and High Sierra):1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080, 2560x1440, 2560x1600, and 3840x2160
OS X (All other versions):1024x768, 1280x960, 1280x1024, 1600x1200, and 1920x1080
You can set the resolution capability as shown in the following example code snippet that sets the value to 1024x768.
// Change resolution to 1024x768DesiredCapabilitiescaps=newDesiredCapabilities();caps.setCapability("resolution","1024x768");
// Change resolution to 1024x768varcapabilities={"resolution":"1024x768"}
// Change resolution to 1024x768// For Chrome browserOpenQA.Selenium.Chrome.ChromeOptionschromeCapability=newOpenQA.Selenium.Chrome.ChromeOptions();capability.AddAdditionalCapability("resolution","1024x768",true);// For Edge browserOpenQA.Selenium.Edge.EdgeOptionsedgecapability=newOpenQA.Selenium.Edge.EdgeOptions();capability.AddAdditionalCapability("resolution","1024x768");// For IE browserOpenQA.Selenium.IE.InternetExplorerOptionsieCapability=newOpenQA.Selenium.IE.InternetExplorerOptions();capability.AddAdditionalCapability("resolution","1024x768",true);// For Firefox browserOpenQA.Selenium.Firefox.FirefoxOptionsfirefoxCapability=newOpenQA.Selenium.Firefox.FirefoxOptions();capability.AddAdditionalCapability("resolution","1024x768",true);// For Safari browserOpenQA.Selenium.Safari.SafariOptionssafariCapability=newOpenQA.Selenium.Safari.SafariOptions();safariCapability.AddAdditionalCapability("resolution","1024x768");
# Change resolution to 1024x768$caps=array("resolution"=>"1024x768");
# Change resolution to 1024x768
capabilities={"resolution":"1024x768"}
# Change resolution to 1024x768caps=Selenium::WebDriver::Remote::Capabilities.newcaps["resolution"]="1024x768"
Sample screenshots before and after resolution change
In the following sample screenshot, for different resolutions, we ran the sample tests to open www.browserstack.com on Chrome 88 browser running on Windows 10:
Resolution - 1024x768
Resolution - 2048x1536
Maximize window with resolution - 2048x1536
The largest supported screen resolution for Windows machines is 2048x1536. If you run the maximize window steps, then your test with the largest screen resolution for Windows as shown in the following image:
Example code snippets
For legacy integration you can set the resolution capability as shown in the following example code snippets.
importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.MutableCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;importjava.net.URL;importjava.util.HashMap;publicclasstestsel4{publicstaticfinalStringURL="https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/";publicstaticvoidmain(String[]args)throwsException{MutableCapabilitiescaps=newMutableCapabilities();caps.setCapability("browserName","chrome");HashMap<String,Object>browserstackOptions=newHashMap<String,Object>();browserstackOptions.put("os","Windows");browserstackOptions.put("osVersion","10");// Set the resolution using the 'resolution' capability.browserstackOptions.put("resolution","1024x768");browserstackOptions.put("buildName","Java Screen Resolution test Sample Build");browserstackOptions.put("sessionName","Screen Resolution test");// Set the selenium version.browserstackOptions.put("seleniumVersion","4.0.0");caps.setCapability("bstack:options",browserstackOptions);WebDriverdriver=newRemoteWebDriver(newURL(URL),caps);driver.get("https://www.browserstack.com");driver.quit();}}
constwebdriver=require('selenium-webdriver');constfs=require('fs')// Input capabilitiesconstcapabilities={'bstack:options':{"os":"Windows","osVersion":"10",'buildName':'NodeJS- Screen Resolution test Sample Build','sessionName':'Screen Resolution test',// Set the resolution using the 'resolution' capability."resolution":"1024x768",// Set the selenium version."seleniumVersion":"4.0.0",},"browserName":"Chrome",}asyncfunctionrunScreenResolution(){letdriver=newwebdriver.Builder().usingServer('https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub').withCapabilities(capabilities).build();awaitdriver.get("https://www.browserstack.com");awaitdriver.quit();}runScreenResolution();
usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingNewtonsoft.Json;usingOpenQA.Selenium;usingOpenQA.Selenium.Chrome;usingOpenQA.Selenium.Remote;namespaceSeleniumTest{classTest{staticvoidMain(string[]args){RemoteWebDriverdriver;ChromeOptionscapabilities=newChromeOptions();capabilities.BrowserVersion="95.0";Dictionary<string,object>browserstackOptions=newDictionary<string,object>();browserstackOptions.Add("os","Windows");browserstackOptions.Add("osVersion","10");// Set the resolution using the 'resolution' capability.browserstackOptions.Add("resolution","1024x768");browserstackOptions.Add("buildName","Csharp- Screen Resolution test Sample Build");browserstackOptions.Add("sessionName","Screen Resolution test");// Set the selenium version.browserstackOptions.Add("seleniumVersion","4.0.0");browserstackOptions.Add("userName","YOUR_USERNAME");browserstackOptions.Add("accessKey","YOUR_ACCESS_KEY");capabilities.AddAdditionalOption("bstack:options",browserstackOptions);driver=newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub/"),capabilities);driver.Navigate().GoToUrl("https://www.browserstack.com/");driver.Quit();}}}
fromseleniumimportwebdriverdesired_cap={'bstack:options':{"os":"Windows","osVersion":"10",# Set the resolution using the 'resolution' capability.
"resolution":"1024x768",# Set the selenium version.
"seleniumVersion":"4.0.0",},"browserName":"Chrome",}driver=webdriver.Remote(desired_capabilities=desired_cap,command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub')driver.get("https://www.browserstack.com")driver.quit()
require'rubygems'require'selenium-webdriver'require'json'#Input Capabilitiescapabilities=Selenium::WebDriver::Remote::Capabilities.newcapabilities={'bstack:options'=>{"os"=>"Windows","osVersion"=>"10","build"=>"Ruby Screen Resolution test Sample Build""name"=>"Screen Resolution test"# Set the resolution using the 'resolution' capability."resolution"=>"1024x768",# Set the selenium version."seleniumVersion"=>"4.0.0",},"browserName"=>"Chrome",}driver=Selenium::WebDriver.for(:remote,:url=>"https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",:desired_capabilities=>capabilities)driver.navigate.to"https://www.browserstack.com"driver.quit
importorg.openqa.selenium.WebDriver;importorg.openqa.selenium.remote.DesiredCapabilities;importorg.openqa.selenium.remote.RemoteWebDriver;importjava.net.URL;publicclasstest{publicstaticfinalStringURL="https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub";publicstaticvoidmain(String[]args)throwsException{DesiredCapabilitiescaps=newDesiredCapabilities();caps.setCapability("os_version","7");caps.setCapability("browser","chrome");caps.setCapability("os","Windows");// Set the resolution using the 'resolution' capability.caps.setCapability("resolution","1680x1050");caps.setCapability("name","Screen Resolution test");// test namecaps.setCapability("build","Java Screen Resolution test Sample Build");// CI/CD job or build nameWebDriverdriver=newRemoteWebDriver(newURL(URL),caps);driver.get("https://www.browserstack.com");driver.quit();}}
constwebdriver=require('selenium-webdriver');constfs=require('fs')// Input capabilitiesconstcapabilities={'browserName':'chrome','os':'windows','os_version':'10','build':'NodeJS- Screen Resolution test Sample Build','name':'Screen Resolution test',// Set the resolution using the 'resolution' capability.'resolution':'1024x768'}asyncfunctionrunScreenResolution(){letdriver=newwebdriver.Builder().usingServer('https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub').withCapabilities(capabilities).build();awaitdriver.get("https://www.browserstack.com");awaitdriver.quit();}runScreenResolution();
usingSystem;usingSystem.IO;usingNewtonsoft.Json;usingOpenQA.Selenium;usingOpenQA.Selenium.Remote;namespaceSeleniumTest{classProgram{staticvoidMain(string[]args){RemoteWebDriverdriver;OpenQA.Selenium.Chrome.ChromeOptionscapability=newOpenQA.Selenium.Chrome.ChromeOptions();capability.AddAdditionalCapability("os_version","10",true);capability.AddAdditionalCapability("os","Windows",true);capability.AddAdditionalCapability("name","Screen Resolution test",true);// test namecapability.AddAdditionalCapability("build","Csharp- Screen Resolution test Sample Build",true);// CI/CD job or build namecapability.AddAdditionalCapability("browserstack.user","YOUR_USERNAME",true);capability.AddAdditionalCapability("browserstack.key","YOUR_ACCESS_KEY",true);// Set the resolution using the 'resolution' capability.capability.AddAdditionalCapability("resolution","1024x768",true);driver=newRemoteWebDriver(newUri("https://hub-cloud.browserstack.com/wd/hub/"),capability);driver.Navigate().GoToUrl("https://www.browserstack.com/");driver.Quit();}}}
fromseleniumimportwebdriverdesired_cap={"browser":"chrome","os":"Windows","os_version":"10",'build':'Python Screen Resolution test Sample Build','name':'Screen Resolution test',# Set the resolution using the 'resolution' capability.
'resolution':'1024x768'}driver=webdriver.Remote(desired_capabilities=desired_cap,command_executor='https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub')driver.get("https://www.browserstack.com")driver.quit()
require'rubygems'require'selenium-webdriver'require'json'#Input Capabilitiescaps=Selenium::WebDriver::Remote::Capabilities.newcaps["os"]="Windows"caps["os_version"]="10"caps["browser"]="chrome"caps["build"]="Ruby Screen Resolution test Sample Build"caps["name"]="Screen Resolution test"caps["javascriptEnabled"]="true"# Set the resolution using the 'resolution' capability.caps["resolution"]="1024x768"driver=Selenium::WebDriver.for(:remote,:url=>"https://YOUR_USERNAME:YOUR_ACCESS_KEY@hub-cloud.browserstack.com/wd/hub",:desired_capabilities=>caps)driver.navigate.to"https://www.browserstack.com"driver.quit
Points to remember
The resolution capability only controls the screen resolution in desktop browsers.
You can set the screen resolution only at the start of a test.
You cannot change the screen resolution during test runtime.
Ensure that screen resolution is large enough when changing browser window size during test runtime so that page elements do not appear off-screen.
Did this page help you?
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback
Test web and mobile, from manual to automation, on real devices in one unified platform.