For android just using tap on phone’s back button (using key event) should do: driver.pressKey(new KeyEvent(AndroidKey.BACK));
For iOS; after tapping on deep link it takes to safari browser.
Browser address element: //XCUIElementTypeOther/XCUIElementTypeTextField[@name=“Address”]
Identify this element and get the value attribute to assert or action on it.
How to switch back to native?
Tap on this element so that clear button gets displayed and tap on clear button. Once again type your app’s scheme name in safari address field (every iOS app will have a scheme name; get this from your developer) e.g: driver.getKeyboard().sendKeys(“schemename://\n”);
This would popup the deep link alert, identify this alert - open button and tap on it - this takes you back to the iOS native app (AUT).