Switch between apps

Hi ,
I have a scenario which I need to switch Apps.
actually, I’m starting with the browser, then I need to have some information from notification bar and then switch back to the browser.
I managed to do each process as a stand-alone. but now I’m struggeling doing it as End to End process.
Thanks in advance

AFAIK this is impossible. If you succeed somehow please update here!
Thanks!

Hi Yaniv_Eliav,

What you need to do is just perform the required action on the browser and then do the following:
// to open notification bar
((AndroidDriver)driver).openNotifications();
// Get the information from Notification bar
String info=driver.findElement(By.id(“Element_on_NotificationBar”)).getText(();
// Switch back to Browser
driver.navigate().back();

and then continue the operations on browser.

Hope this resolves your problem :smile:

Regards,
@Abdul_Sathar_Beigh

Thank you for the response Abdul_Sathar_Beigh.
I will give it a chance later today.
According to your suggestion, I believe that the opened session needs to be the chrome driver and the AndroidDriver is a manipulation which doesnt need to be opened as a session. Correct?

Yes you are correct :slightly_smiling:

1 Like

In Android this is possible, but it is not possible on IOS.

Abdul_Sathar_Beigh
Unfortunately, I’m getting the next error:

Result Message:	System.InvalidCastException : Unable to cast object of type 'OpenQA.Selenium.Remote.RemoteWebDriver' to type 'OpenQA.Selenium.Appium.Android.AndroidDriver`1[OpenQA.Selenium.Appium.AppiumWebElement]'.

Hi Yaniv_Eliav,

Maybe you are not casting the driver object properly. Can you just post code so that I can help you with that.

Regards,
@Abdul_Sathar_Beigh

Hi Abdul_Sathar_Beigh,
Thank you.
eventually , I managed (Thanks to another user here @jitenderbhardwaj ).
The solution was to Change to NATIVE_APP and then back to WEBVIEW_1 context.

Hi @Abdul_Sathar_Beigh

This is working spot on Android,

But for IOS I tired below things to go back to App…
//Using xpath -
driver.findElement(By.xpath("//UIAButton[@name =‘back to app’]"));

//for this I’m getting instruments crash error and some time null pointer excpetions

//Using BackButton

driver.navigate().back()
//this is doing nothing…

Any suggestions for IOS to go back to app

Below is how i achieved it using python:

context.driver = Driver()

context.driver.instance.start_activity(package name of the activity to be launched,
activity name )
#do something on this activity

context.driver.instance.start_activity(package name of another activity to be launched,
activity name)
#do something on this activity