Can we handle browser opened by clicking on link present in Native application

Hi,

I am using Android application and just wanted to know if we can handle and perform action on the browser opened by clicking on link present in Native application.

So if I am staring a native application through Appium and there is link(“TextView”) on the application clicking on it will open a website on the mobile default browser. Is there any way we can handle this by Appium and perform furthur actions on the webbrowser.
I tried to get the context its showing only “NATIVE_APP”.

Please let me know if anyone have solution for this.

Regards,
Nishant Singh

Are you getting the context after clicking on the TextView ? I’m quite sure it should show you a WEBVIEW_something contexts.

No as its opening in the browser window separately not in the same application window when I use driver.getContextHandler its gives only NATIVE_APP nothing else.

Why driver.getContextHandler and not driver.getContexts ? Also, have you try asking for it with a timeout after clicking on the TextView. Maybe wait for some seconds and them ask for it again.

Yes I am waiting for the page to load and then trying to get the context even I tried as you suggested getting the same result only NATIVE_APP. Sorry to say this instead of asking such stupid question like I am waiting or not if you really want to help just download the app from https://play.google.com/store/apps/details?id=com.afrogleap.eneco.myeneco and then open it Click on the first button you see on the first page and then click on the “Registreren” link present on the next page it will open a browser with a register page just let me know how you will handle the browser that would be a great help.

Do you have any test already created I can help you with ? Which language are you using ? I could give a hand on python or nodejs.

Hi,

Thanks… I am using Java if you could help me with Java its good otherwise if you could be able to do it in Python also no problem I will try to change it into java just need to know if we could handle this browser window with Appium.

This is what I have done in java:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“BROWSER_NAME”, “Android”);
capabilities.setCapability(“VERSION”, “5.0.2”);
capabilities.setCapability(“deviceName”,“XT1068”);
capabilities.setCapability(“platformName”,“Android”);
capabilities.setCapability(“appPackage”, “com.afrogleap.eneco.myeneco”);
capabilities.setCapability(“appActivity”,“com.afrogleap.eneco.myeneco.activity.SplashActivity”);

driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
driver.findElementByName(“Inloggen”).click();
WebDriverWait ww = new WebDriverWait(driver,30);
ww.until(ExpectedConditions.elementToBeClickable(By.name(“Registreren”)));
driver.findElementByName(“Registreren”).click();
Thread.sleep(15000);
System.out.println(driver.getPageSource());
System.out.println(“Context” + driver.getContext());
Set st = driver.getContextHandles();
System.out.println(“Context Handle” +st);

hey @NishantSingh I have created a test with my own app, but as you i’m facing the same problem. I’m not getting the WEBVIEW context after opening the browser from the app. I’ll research a little more and let you know.

Also added an issue on github, maybe there they can answer quickly if this is possible to implement.

@vrunoa Thanks a lot… Let see if we get any solution for this.