The app that I am testing contains hyperlinks that if tapped result in an external browser being opened, with focus moving from the app to the external browser. I can detect that the app is no longer in the foreground using WaitForNoElement, but I need then to get the focus back to the app to continue with the remainder of the test. Calling app.Back() does not do it. I imagine I could use a backdoor to do it, but think there must be an easier way. Can anyone advise please?
Many thanks,
John H.
Answers
Bump.
Does anybody know how to bring a running app back to the foreground again after following a link (or otherwise) to another app?
Many thanks,
John H.
I can call StartApp again, but that does not foreground an already running app. It also means that any references to object (e.g. the main page of the app) are invalidated, so neither a complete solution nor a particularly great workaround.
Hi John,
Once the app passes off to an external browser, which is a different app, it is out of UITests control to bring it back. Based on the above i assume the state of the app is different after a visit to the web page. If possible, i'd suggest composing your tests in such a way that one of them tests the passing off to the external browser (as you have already done using WaitForNoElement) and the other tests the state of the app after a visit to the web page.
This could be done by setting up a particular state before the test runs and navigating into the app. As you mentioned this could potentially be done using a backdoor method.
You might also be able to use the start app method as follows:
Cheers,
David
@DavidLavender - A thought just occurred to me... Presumably, it would be possible to control more than one app from the UITest, one IApp referencing the AUT, and another IApp for each app that a hyperlink takes the user to (assuming I know where that will be, of course)? ConnectToApp, InstalledApp etc. could presumably be used to hook up the second and subsequent apps?
It might be a tad painful, but by taking control of those other apps etc., it should hopefully be possible to navigate back and forth...
Thanks,
John H.