Switch to app switcher and open app without relaunching UITesting

I wish to switch to and from app switcher while automation for my test case to check the visibility of the content in my app when it's in app switcher stack.

While I'm searching I found an option XCUIDevice Button press to go to home screen.

XCUIDevice.shared.press(.home)
sleep(10)
XCUIApplication().launch()

Although I can't view my app in app switcher stack, hence can't fulfil my test case.

Also, I tried to do some work around like enabling Assistive Touch and try to use the App Switcher option from there. But I can't find the assistive touch element to utilise it.

Is there any other way I need to try? 🔎

Thanks in advance...

app.activate tried this to bring back the app state without relaunch. Still looking for a solution to view the app in app switcher

Switch to app switcher and open app without relaunching UITesting
 
 
Q