-1

To check the Dark Appearance Toggle is ON for XCUI TEST, can anyone please rectify me as in below code , the flow is not coming inside the if loop, i am using below code. Code is Below -

    if !settings.switches["Dark Appearance"].isEnabled
    {
        settings.switches["Dark Appearance"].tap()
    }

Please find attached Screenshot . enter image description here

  • Does this answer your question? [How can I check whether dark mode is enabled in iOS/iPadOS?](https://stackoverflow.com/questions/56435720/how-can-i-check-whether-dark-mode-is-enabled-in-ios-ipados) – Mr.SwiftOak Sep 06 '22 at 07:21
  • Thanks for suggestion , however the logic i am looking for the if loop , just to check whether the dark mode toggle is on or not , and if not , then I just want to click m Which i know how to click , so just looking for if loop syntax – Ankit Gupta Sep 06 '22 at 10:14

1 Answers1

1

Finally worked, so can be closed

 if UITraitCollection.current.userInterfaceStyle == .light
 {
    settings.switches["Dark Appearance"].tap()
 }
Ved
  • 938
  • 2
  • 5
  • 19