Skip to main content

Set Device Dark Mode

Real Device Virtual Device

LambdaTest now allows you to enable or disable dark mode for automation testing as well. This helps developers and testers validate UI behavior across light and dark themes, theme switching without manual intervention, and visual consistency for mobile apps and web applications.


Use Cases

Mobile App Testing

  • Ensure UI elements render correctly in dark mode
  • Check text contrast and readability
  • Verify icon and image visibility in dark backgrounds
  • Confirm theme consistency across screens

Web Testing

  • Test CSS media queries for prefers-color-scheme: dark
  • Validate dark theme implementations in your app
  • Check browser-level dark mode support
  • Review responsiveness across both themes
info

This feature works for both Virtual and Real Devices.

Supported Platforms

PlatformVersion
iOS13 and above
Android11 and above

Enabling Dark Mode via Capabilities

You can enable the dark mode setting through darkMode capability before the session starts. This ensures the device starts in the dark theme without additional steps during test execution.

{
"deviceName":"iPhone 16",
"platformName":"ios",
"platformVersion":"18",
"isRealMobile":True,
"app":"YOUR_APP_URL",
"darkMode": true
}
info

Enabling Dark Mode via Hooks

To change dark mode settings during test execution, use the hook with the updateDeviceSettings action. The example below demonstrates this using Python.

driver.execute_script('lambda_executor: { 
"action": "updateDeviceSettings",
"arguments": {
"darkMode" : "on"
}
}')
tip
  • Dark mode changes are applied at the system level and may require app restarts for full effect
  • Some legacy applications may not fully support dark mode theming
  • Web applications must implement their own dark mode CSS for the setting to take effect beyond browser UI

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

Book Demo

Help and Support

Related Articles