Basim Sherif
Basim Sherif

Reputation: 5440

Select text inside edittext in Espresso

I want to select a text inside edittext so that I can check copy and paste option using Espresso. What I have tried is ,

onView(withText("text")).perform(longClick());

This will perform a long click in Edittext. But text is not selected.

Upvotes: 1

Views: 1579

Answers (1)

piotrek1543
piotrek1543

Reputation: 19351

for simple "catching" part of text you would use Hamcrest matchers like containsString(), startsWith(), endsWith().

Although, as you said, you need to match a specific text to copy it and paste it in another place.

I think it might be pretty impossible to test it with Espresso. You may need to take this action another UI testing tool called UI Automator.

UI Automator, another great tools made by Google, allows you to test your Android system functions like notifications, screen lock or copy and paste operations. It's working pretty well with Espresso test framework.

For finding more info, please read this article:

http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html

Hope it help.

Upvotes: 1

Related Questions