appium/java-client

No Chrome browser web context after browser termination and relaunch

wazzeps opened this issue · 7 comments

Description

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

Environment

  • Java-client 8.5.0
  • Appium 2.1.3
  • uiautomator2@2.31.4
  • Android emulator

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

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

@mykola-mokhnach could you please look into?

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

Yes I can connect and open tabs with remote debugger.

image

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

Appium logs

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

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