How to check the Toggle is ON for XCUI TEST

Viewed 32

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

1 Answers

Finally worked, so can be closed

 if UITraitCollection.current.userInterfaceStyle == .light
 {
    settings.switches["Dark Appearance"].tap()
 }
Related