David
David

Reputation: 910

Check if a view is displayed in WebView with Espresso

How can I check that a view (any view, TextBox, Button) is displayed in a WebView, using Espresso?

I have tried with the following, but I'm not able to finish the check:

onWebView().withElement(findElement(ID, "username")).check( ... )

Upvotes: 3

Views: 4968

Answers (1)

Just change this:

onWebView().withElement(findElement(ID, "username")).check( ... )

with this:

onWebView().check(webContent(hasElementWithId("username"));

Worked for me.

Upvotes: 1

Related Questions