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.
Setting the Capability
If you are using BrowserStack SDK, you can set the following capabilities in the browserstack.yml
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 (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
.
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
The following example code snippet shows how the resolution
capability can be used to set custom screen resolutions for BrowserStack SDK integration:
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
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.
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
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!