Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch between apps

I have a scenario which I need to switch Apps by using Selenium and Appium. 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 struggling doing it as End to End process.

I have started by creating a webdriver session, but I can't open a new session while he first one is still running. the problem is that the browser and appium have different sessions. One is being called by

_driver = new AndroidDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(180));

And the second one by

_webdriver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(180));
like image 762
JumpIntoTheWater Avatar asked Oct 30 '22 09:10

JumpIntoTheWater


1 Answers

I managed to do what needed. All I needed to do is to run AndroidDriver first with Chrome appActivity and appPackage.

Then, use driver.Context = NATIVE_APP; in order to use the Android's activities. going back to chrome is pretty easy as well. driver.context = "WEBPAGE_1"; this syntax belongs to C#.

in order to know which context you are currently using, use this code:

var Handledcontext=driver.Context.Tostring();

good luck and thank you all for trying helping me.

like image 127
JumpIntoTheWater Avatar answered Nov 15 '22 05:11

JumpIntoTheWater