Set Device Dark Mode
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
Platform | Version |
---|---|
iOS | 13 and above |
Android | 11 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.
- iOS
- Android
{
"deviceName":"iPhone 16",
"platformName":"ios",
"platformVersion":"18",
"isRealMobile":True,
"app":"YOUR_APP_URL",
"darkMode": true
}
{
"deviceName":"Galaxy S20",
"platformName":"Android",
"platformVersion":"10",
"isRealMobile":True,
"app":"YOUR_APP_URL",
"darkMode": true
}
info
- You must add the generated APP_URL to the
app
capability in the config file. - You can generate capabilities for your test requirements with the help of our inbuilt Capabilities Generator tool.For more details, please refer to our guide on Desired Capabilities in Appium.
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.
- Real Devices
- Virtual Devices
driver.execute_script('lambda_executor: {
"action": "updateDeviceSettings",
"arguments": {
"darkMode" : "on"
}
}')
driver.execute_script('lambdatest_executor: {
"action": "updateDeviceSettings",
"arguments": {
"DarkMode": "true"
}
}')
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