Skip to main content

Change Browser Window Size

When running Selenium tests on TestMu AI, you can control the browser window resolution to test responsive layouts, verify UI elements at specific breakpoints, and reproduce resolution-dependent bugs. Set the resolution through the resolution capability in LT:Options.

Set Resolution Using the resolution Capability


Pass a resolution string in LT:Options to launch the browser at a specific screen size.

Add the resolution capability to your LT:Options configuration. The value is a string in the format widthxheight. If you do not specify a resolution, TestMu AI defaults to 1024x768.

ResolutionTest.java
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.net.URL;
import java.util.HashMap;

public class ResolutionTest {
public static void main(String[] args) throws Exception {
ChromeOptions browserOptions = new ChromeOptions();
browserOptions.setPlatformName("Windows 11");
browserOptions.setBrowserVersion("latest");

HashMap<String, Object> ltOptions = new HashMap<>();
ltOptions.put("username", System.getenv("LT_USERNAME"));
ltOptions.put("accessKey", System.getenv("LT_ACCESS_KEY"));
ltOptions.put("resolution", "1920x1080");
ltOptions.put("project", "Resolution Test");
browserOptions.setCapability("LT:Options", ltOptions);

RemoteWebDriver driver = new RemoteWebDriver(
new URL("https://hub.lambdatest.com/wd/hub"), browserOptions);
driver.get("https://example.com");
driver.quit();
}
}

Supported Resolutions


Choose from these predefined screen resolutions when setting the resolution capability.

ResolutionAspect RatioCommon Use
1024x768 (default)4:3Legacy desktops, older monitors
1280x80016:10Older laptops
1280x10245:4Standard desktop monitors
1366x76816:9Budget laptops, common breakpoint
1440x90016:10MacBook and mid-range laptops
1680x105016:10Large desktop monitors
1600x12004:3Large standard monitors
1920x108016:9Full HD monitors and laptops
1920x120016:10Professional desktop monitors
2048x15364:3High-resolution displays
2560x144016:9QHD monitors
note

Supported resolutions are OS-dependent. Use the Capabilities Generator to verify which resolutions are available for your target OS and browser.

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles