Search code examples
appiumappium-ios

How can i set Dark/Light mode on iOS using appium


I have tried the below code block in @Before and nothing happens the test passed with no error but device mode did not change to dark

((JavascriptExecutor)driver).executeScript("mobile:setAppearance", "{style: 'dark'}");


Solution

  • This command is an alias to the xcrun simctl ui command which is only applicable to the simulators.

    The only way to do this on a real device is to open Settings -> Display & Brightness and click on Dark mode. You can see some details on this topic