Simulate user click in system activities with Android Espresso framework

503 views Asked by At

In my application I'm turning on BlueTooth when first Activity starts up. It results in the system dialog asking for the authorization to activate the BlueTooth.

How can I asset that this dialog is present and click on the "Yes" Button with Espresso ? Is it possible ?

I tried the following but the view is not found in the layout hierarchy.

onView(withText("Bluetooth")).check(matches(isDisplayed()));

I guess this is because it's a system Activity.

Thank you.

1

There are 1 answers

0
denys On BEST ANSWER

You can use UIAutomator for this purpose. It is possible to combine Espresso tests with UIAutomator in one test case. The only limitation is that it requires API level 18+ which can be achieved by adding flavor in your build.gradle file.