Cannot target click on Like icon

42 views
Skip to first unread message

Terry Newman

unread,
May 25, 2024, 11:19:36 PMMay 25
to Automate for Android
Hello, I'm trying to automate a test for my app, but cannot get Interact > Click to affect the Like icon button. 

Screenshot_20240525-230717.png
Here is the XML for my React Native app:
<android.view.ViewGroup android:enabled="true" android:layout_height="77px" android:layout_width="1008px" android:layout_x="36px" android:layout_y="1510px">
<android.view.ViewGroup android:clickable="true" android:enabled="true" android:focusable="true" android:layout_height="44px" android:layout_width="71px" android:layout_x="36px" android:layout_y="1510px">
<android.widget.ImageView android:enabled="true" android:layout_height="40px" android:layout_width="53px" android:layout_x="36px" android:layout_y="1510px"/>
</android.view.ViewGroup>
<android.view.ViewGroup android:clickable="true" android:enabled="true" android:focusable="true" android:layout_height="38px" android:layout_width="143px" android:layout_x="107px" android:layout_y="1513px">
<android.widget.TextView android:enabled="true" android:layout_height="38px" android:layout_width="72px" android:layout_x="107px" android:layout_y="1513px" android:text="0 LIKES"/>
</android.view.ViewGroup>
<android.view.ViewGroup android:clickable="true" android:enabled="true" android:focusable="true" android:layout_height="44px" android:layout_width="62px" android:layout_x="250px" android:layout_y="1510px">
<android.widget.ImageView android:enabled="true" android:layout_height="36px" android:layout_width="53px" android:layout_x="250px" android:layout_y="1514px"/>
</android.view.ViewGroup>
<android.widget.TextView android:enabled="true" android:layout_height="44px" android:layout_width="35px" android:layout_x="388px" android:layout_y="1510px" android:text="25d"/>
<android.view.ViewGroup android:clickable="true" android:enabled="true" android:focusable="true" android:layout_height="38px" android:layout_width="147px" android:layout_x="495px" android:layout_y="1513px">
<android.widget.TextView android:enabled="true" android:layout_height="38px" android:layout_width="76px" android:layout_x="495px" android:layout_y="1513px" android:text="REPORT"/>
</android.view.ViewGroup>
</android.view.ViewGroup>

I've tried the following XPath Expressions, but the Like button won't click:
  • //android.view.ViewGroup[android.view.ViewGroup[android.widget.TextView[@text='0 LIKES']]]//android.widget.ImageView[@enabled='true']
  • //android.widget.TextView[@text='0 LIKES']/preceding-sibling::android.view.ViewGroup/android.widget.ImageView
  • //android.view.ViewGroup[android.view.ViewGroup[android.widget.ImageView[@enabled='true' and @layout_height='40px' and @layout_width='53px' and @layout_x='36px' and @layout_y='1510px']] and android.view.ViewGroup[android.widget.TextView[@text='0 LIKES']]]/android.widget.ImageView[@enabled='true' and @layout_height='40px' and @layout_width='53px' and @layout_x='36px' and @layout_y='1510px']
Any ideas? 




Henrik "The Developer" Lindqvist

unread,
May 26, 2024, 4:25:54 AMMay 26
to Automate for Android
Try:
//android.widget.TextView[@android:text='0 LIKES']/..

Terry Newman

unread,
May 26, 2024, 7:13:06 AMMay 26
to Automate for Android
Thanks for the tip, but unfortunately it didn't work. 

It's not actually the TextView that is clickable, nor the ViewGroup it's nested in - if you look at the graphic in relation to the XML, it's the preceding sibling ViewGroup that is clickable (which has the ImageView (ie: the heart icon) nested within).

Henrik "The Developer" Lindqvist

unread,
May 26, 2024, 3:12:10 PMMay 26
to Automate for Android
Try:
//android.widget.TextView[@android:text='0 LIKES']/../preceding-sibling::android.view.ViewGroup
Reply all
Reply to author
Forward
0 new messages