Issue
I have a layout that contains a textview, shown below that will contain some auto generated links in a block of text. When the user clicks the links, a window with relevant information is opened up.
However, I cannot figure out how to get Espresso to click on the links at all. Have tried many variations of something like
matches(withText(containsString("45")))
but this either just doesn't work or makes espresso just click on the textbox itself, which doesn't do anything.
Is there any way to do this? Is it even possible within the limitations of Espresso?
Solution
You can use openLinkWithText(String linkText)
Returns an action that opens a link matching the given link text and uri matchers. The action is performed by invoking the link's onClick method (as opposed to actually issuing a click on the screen).
Here's an example to how to use it :
Espresso.onView(ViewMatchers
.withId(R.id.your_text_view_id))
.perform(ViewActions.openLinkWithText("45"));
References : espresso-recipes-for-android
Answered By - Skizo-ozᴉʞS

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.