java-client icon indicating copy to clipboard operation
java-client copied to clipboard

No Chrome browser web context after browser termination and relaunch

Open wazzeps opened this issue 2 years ago • 7 comments

Description

After calling the terminateApp(String bundleId) method to close Chrome browser it has no web context after subsequent launch.

Environment

Details

We navigate from the application to the Chrome browser using a link, after which we clear the state of the browser, closing all tabs and destroying the browser. When we try to navigate from the application to the browser again, the driver does not find web context.

Code To Reproduce Issue [ Good To Have ]

Test 1

// tap a link in the app
// wait for the browser to open

((SupportsContextSwitching) driver).context("WEBVIEW_chrome");
driver.getWindowHandles().forEach(windowHandle -> driver.switchTo().window(windowHandle).close());
((InteractsWithApps) driver).terminateApp("com.android.chrome");

Test 2

// tap a link in the app
// wait for the browser to open

System.out.println(((SupportsContextSwitching) driver).getContextHandles());

Output: [NATIVE_APP]

Link To Appium Logs

Appium logs

wazzeps avatar Oct 31 '23 23:10 wazzeps

Setting ensureWebviewsHavePages capability to false allows the driver to see the context but not switch to it.

wazzeps avatar Oct 31 '23 23:10 wazzeps

@mykola-mokhnach could you please look into?

wazzeps avatar Nov 20 '23 20:11 wazzeps

Maybe the context is really not connectable. Are you able to connect to it with Chrome remote debugger in such state?

mykola-mokhnach avatar Nov 20 '23 21:11 mykola-mokhnach

Yes I can connect and open tabs with remote debugger.

image

wazzeps avatar Nov 23 '23 18:11 wazzeps

Sometimes I can see both contexts, but switching is not completed within the allotted time.

Appium logs

wazzeps avatar Nov 23 '23 18:11 wazzeps

Unfortunately I don't know how we can help there. Maybe try to report the issue to chromedriver.

mykola-mokhnach avatar Nov 23 '23 18:11 mykola-mokhnach

appium:showChromedriverLog may show more information. Although it looks like Chrome or chromedriver side's something.

Not for the version, but chrome v115+ has similar issue https://bugs.chromium.org/p/chromedriver/issues/detail?id=4595

KazuCocoa avatar Nov 23 '23 18:11 KazuCocoa