Does Espresso support other app developed using react native?

188 views
Skip to first unread message

surya....@coupa.com

unread,
Jun 3, 2018, 2:42:01 AM6/3/18
to Android Testing Support Library
I am planning to implement Espresso my our native mobile application which is developed in react native? Does Espresso support UI automation of these native applications other than developed using Java? If yes, are there any useful links for me get started?

Luis Ramirez

unread,
Jun 3, 2018, 5:35:08 PM6/3/18
to surya....@coupa.com, Android Testing Support Library
On Sun, Jun 3, 2018 at 1:42 AM <surya....@coupa.com> wrote:
I am planning to implement Espresso my our native mobile application which is developed in react native? Does Espresso support UI automation of these native applications other than developed using Java?

Since React Native is supposed to translate to real native widgets on the platform it's running on, you should be able to drive tests through Espresso, theoretically.
 
If yes, are there any useful links for me get started?

A quick Google search for "react native espresso" shows some promising StackOverflow and Medium posts.

Have you tried just writing a simple test and seeing if it works at all? Is there any specific problem you're running into? 

Gaurav Dalal

unread,
Aug 28, 2018, 4:10:52 AM8/28/18
to Android Testing Support Library
Espresso doesn't work for React-native apps. There are certain post about reading the components via 'content-description' but it does not work. 
If it worked for you using Espresso - do let us know here!

The way it works for react-native screens/apps is by using UiAutomator support classes. Do take a look at google searches for "react native UiAutomator" keyword. UiAutomator classes works best with react-native apps/screens. 

surya....@coupa.com

unread,
Aug 28, 2018, 4:32:06 PM8/28/18
to Android Testing Support Library
I tried clicking couple of elements on react native page and it worked for me. Did you see scenarios that did not work? Please let us know.

Gaurav Dalal

unread,
Aug 28, 2018, 11:04:14 PM8/28/18
to Android Testing Support Library
I was using it like below and it didn't work for me ...

onView(allOf(withContentDescription("SelectAnItem"), isDisplayed())).perform(click());

just tried to access the react native components like this. 

Q1) How does it work for you, can you explain a little ? 
Q2) Did you do some categorisation between dev and release builds before writing/running the tests ?

surya....@coupa.com

unread,
Aug 29, 2018, 1:47:28 AM8/29/18
to Android Testing Support Library
Gaurav,

I used below code and it worked for me, looks like you might also have to use id with content-description combination.

        ViewInteraction actionMenuItemView = onView(allOf(withId(R.id.wallet_menu_item), withContentDescription("React Element"), isDisplayed()));
        actionMenuItemView.perform(click());
Reply all
Reply to author
Forward
0 new messages