Page 1 of 1
how to ensure you get to the home or main screen of an app
Posted: 28 Aug 2019 06:42
by tsolignani
I have several flows with control UI (love it!) where the flow needs the app to be into its main or home page to work. If I try to kill the app and realunch it many times it doesn't work (it doesn't quit, even when in background).
Is there any other way to make sure an app is in its main page when activated, as when launched for the first time?
Thank you.
Re: how to ensure you get to the home or main screen of an app
Posted: 29 Aug 2019 19:15
by Desmanto
How about adding back() several times to ensure it always back-ed until the main page of the app. This varies depends on the app. You can add additional check for certain element in the app before executing the main script. Example if the app is now in level 2, you can use back(); sleep(100); back(), to back twice to the main screen. Check for any element Id that might be there using existsElementById(), choose the element that only appear at the sub menu level 2. Do the same also for other sub menu.
Or you can make universal back() if there is certain element that only exists in main screen. So the script will loop back() if this element is not exists. Example for Gmail, the search box is always in the main screen.
Code: Select all
loop = 0;
if(!existsElementById("com.google.android.gm:id/open_search") AND loop <= 5)
{
back();
loop = loop + 1;
sleep(100);
}
This ensure it will press back() until it back to main screen. I add check for loop is less than equal to 5. This protect so the back is only pressed maximum 5 times, in case you mis-run the script not inside Gmail.
Re: how to ensure you get to the home or main screen of an app
Posted: 30 Aug 2019 07:12
by tsolignani
Just great! Thank you so much. I am not only fixing my flows, but learning many things.
Have a nice day.
Re: how to ensure you get to the home or main screen of an app
Posted: 30 Aug 2019 15:23
by tsolignani
It does work! Wonderful. Thanks again.