1

I have an app in which users can search for a text and it will populate the related repositories from Github based on that text/search term.I want to write an espresso test to verify that when user searches for a term the list of repo's is displayed and when user clicks on the first repo displayed in the list it opens up the respective github webpage in chrome browser in the phone.

I am able to to perform those steps using below code but not getting the idea of how to assert/verify that indeed the link opens in the chrome browser.

@Rule @JvmField
var mActivityTestRule = ActivityTestRule(MainActivity::class.java)


@Test
fun searchFunctionality() {

onView(withId(R.id.SearchEditText)).perform(click()).perform(clearText())
onView(withId(R.id.SearchButton)).perform(click())
Thread.sleep(2000)
onData(anything()).inAdapterView(allOf(withId(R.id.repoListView))).atPosition(0).perform(click())
 //how to assert/verify that chrome browser opens after the above click action happens?

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.