3

We have more than 400 UI tests written using espresso running locally in Android Studio and remotely on continuous integration system.

Some of these tests check if the mobile application opens an http url with Chrome. In our test suite we verify if chrome is running using the following method:

fun waitChrome(device: UiDevice): UiObject2? {
    return device.wait(Until.findObject(By.pkg("com.android.chrome")), 2500)
}

Last week,maybe an update of gradle depencencies causes test failures. Chrome is not opened anymore during the execution of these tests. In order to fix these failures I changed the implementation of the above method:

fun waitChrome(device: UiDevice): UiObject2? {
    return device.wait(Until.findObject(By.pkg("org.chromium.webview_shell")), 2500)
}

A System WebView Shell is launched instead of Chrome App on Continuous Integration System.

I would like to know it there is a way to restore the usage of Chrome during the execution of these tests. Maybe some parameter can be passed when the emulator starts.

chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31
  • 1. What is the error message you are receiving while using com.android.chrome? 2. Have you tried running the same test in real device? – sak Sep 24 '21 at 15:53
  • Just device.wait(Until.findObject(By.pkg("com.android.chrome")), 2500) fails since an object with package "com.android.chrome" in the view hierarchy is not found anymore. To fix this failure I have changed the implementation of the waitChrome method as described above and the tests start running successfully again. – chiarotto.alessandro Sep 24 '21 at 15:57
  • I'm guessing that opening a chrome is test request in this case, but not every device uses chrome, so only relevant thing that you can use for testing opening URL in another app is espress-intents (https://developer.android.com/training/testing/espresso/intents) – robigroza Sep 27 '21 at 12:33
  • did you try it on a physical device? I think it is a device issue. – user16930239 Sep 27 '21 at 14:20
  • Yes we tried on device and chrome run correctly. – chiarotto.alessandro Sep 27 '21 at 14:27

2 Answers2

1

Maybe System WebView Shell is launched instead of Chrome App on Continuous Integration System because when the emulator is created, it is not used google_apis_playstore in abi and package. You can try to use this configuration instead of google_apis.

mike5v
  • 614
  • 5
  • 13
0

You can control whether the related activity is fired instead of the package name.

sample activity

"com.android.chrome/com.google.android.apps.chrome.Main"

Sample code

Espresso - How can I check if an activity is launched after performing a certain action?

Arda Kazancı
  • 8,341
  • 4
  • 28
  • 50