Open urbanclap-admin opened 10 months ago
Tried chaining it with multiple ancestor matchers like below
let address = element( by .id("location_heading") .withAncestor( by .id("location_heading_ll") .withAncestor( by .id("location_heading_ll_ll") .withAncestor( by .id("location_heading_ll_ll_ll") .withAncestor(by.id("location_list_parent")) ) ) ) );
this also did not work
view hierarchy would looks something like this -
ListView -> LinearLayout -> LinearLayout -> LinearLayout -> TextView
@noomorph can you please help here?
Try adb shell uiautomator dump
Try adb shell uiautomator dump
here is the dump file
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><hierarchy rotation="0"><node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2138]"><node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,2138]"><node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,1507]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/action_bar_root" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,1507]"><node index="0" text="" resource-id="android:id/content" class="android.widget.FrameLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,1507]"><node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,1507]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/locationScreenContainerUi" class="android.view.ViewGroup" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,1507]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/toolbar" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,521]"><node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][1080,275]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/itv_arrow" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,136][132,275]" /><node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[132,169][1080,255]"><node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[132,169][1080,230]"><node index="0" text="Vikas Puri Cricket Coa" resource-id="com.urbanclap.urbanclap:id/et_search" class="android.widget.EditText" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="true" scrollable="false" long-clickable="true" password="false" selected="false" bounds="[132,169][964,230]" /><node index="1" text="" resource-id="com.urbanclap.urbanclap:id/itv_clear_search_text" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[964,172][1014,230]" /></node><node index="1" text="" resource-id="" class="android.view.View" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[132,252][1014,255]" /></node></node><node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[14,297][1080,433]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/uc_animation_bulb_view" class="android.widget.ImageView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[14,310][124,420]" /><node index="1" text="" resource-id="com.urbanclap.urbanclap:id/text_switcher" class="android.widget.TextSwitcher" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[124,297][806,433]"><node index="0" text="eg. Marina Road or Redfern or DLF City Phase 4" resource-id="" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[124,345][806,384]" /></node></node></node><node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,587][1080,1061]"><node index="1" text="" resource-id="com.urbanclap.urbanclap:id/location_screen_place_list" class="android.widget.ListView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false" scrollable="true" long-clickable="false" password="false" selected="false" bounds="[0,587][1080,895]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/container" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="true" bounds="[0,587][1080,697]"><node index="0" text="Delhi" resource-id="com.urbanclap.urbanclap:id/text1" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[44,626][1080,672]" /></node><node index="1" text="" resource-id="com.urbanclap.urbanclap:id/container" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,697][1080,895]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/ll_location_text_container" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,697][1080,895]"><node index="0" text="" resource-id="com.urbanclap.urbanclap:id/icon_text_view" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[44,741][94,799]" /><node index="1" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[94,741][1036,851]"><node index="0" text="Vikas Puri Cricket Coaching Center" resource-id="com.urbanclap.urbanclap:id/tv_location_heading" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[138,741][1036,795]" /><node index="1" text="Block GG 2, Vikaspuri, New Delhi, Delhi, India" resource-id="com.urbanclap.urbanclap:id/tv_location_text" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[138,806][1036,851]" /></node></node></node></node><node index="2" text="" resource-id="com.urbanclap.urbanclap:id/ll_powered_by_google_container" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,950][1080,1061]"><node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[368,1005][712,1061]"><node index="0" text="powered by" resource-id="" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[368,1005][560,1061]" /><node index="1" text="" resource-id="" class="android.widget.ImageView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[574,1005][712,1052]" /></node></node></node></node><node index="1" text="" resource-id="" class="android.widget.ImageView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,1342][1080,1507]" /></node></node></node></node></node><node index="1" text="" resource-id="android:id/statusBarBackground" class="android.view.View" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][1080,136]" /><node index="2" text="" resource-id="android:id/navigationBarBackground" class="android.view.View" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[0,0][0,0]" /></node></hierarchy>
Hmm... Looks like it is tv_location_heading
, you mistyped location_heading
.
<node index="0" text="Vikas Puri Cricket Coaching Center"
resource-id="com.urbanclap.urbanclap:id/tv_location_heading"
class="android.widget.TextView"
package="com.urbanclap.urbanclap" content-desc=""
checkable="false" checked="false" clickable="false"
enabled="true" focusable="false" focused="false"
scrollable="false" long-clickable="false" password="false"
selected="false" bounds="[138,741][1036,795]"/>
Hmm... Looks like it is
tv_location_heading
, you mistypedlocation_heading
.<node index="0" text="Vikas Puri Cricket Coaching Center" resource-id="com.urbanclap.urbanclap:id/tv_location_heading" class="android.widget.TextView" package="com.urbanclap.urbanclap" content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[138,741][1036,795]"/>
that is the id of the view not the tag value from which detox actually fetches the view using by.id() matcher
So, did you check that those tags (location_heading
) are present in the hierarchy?
Maybe you could avoid long ancestor chains and just use atIndex
in case there are multiple instances (although I see only one instance, hm, then why use so specific selectors)?
element(by.id('location_heading')).atIndex(0);
Besides, you can try to inspect your hierarchy with Detox (latest Detox, 20.13.x allows that in Android) – just pick some element type that interests you and query the attributes:
console.log(await element(by.type('android.widget.TextView')).getAttributes());
So, did you check that those tags (
location_heading
) are present in the hierarchy? Maybe you could avoid long ancestor chains and just useatIndex
in case there are multiple instances (although I see only one instance, hm, then why use so specific selectors)?element(by.id('location_heading')).atIndex(0);
Besides, you can try to inspect your hierarchy with Detox (latest Detox, 20.13.x allows that in Android) – just pick some element type that interests you and query the attributes:
console.log(await element(by.type('android.widget.TextView')).getAttributes());
none of the suggestions work sadly
just tried various combinations to check if something works, not sure why it is not working, would really appreciate ur help here
And what do you see there?
console.log(await element(by.type('android.widget.TextView')).getAttributes());
Hm, try an extended search like this:
const { elements } = await element(by.type('android.view.View')).getAttributes();
console.log(elements.filter(x => x.text.trim() || x.identifier)); // let's not overspam the results
not sure why this works but
once I do
await element(by.type('android.widget.TextView')).getAttributes()
I can now fetch the element just by the text matcher itself, without the attributes code this does not work, also works with atindex matcher as well
can you please explain the background behind this? my hunch is with the getAttributes call it syncs correctly with the view hierarchy I guess
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this repository, read this discussion.
What happened?
not able to find an element that is a child of ListView on native Android. the view is native only.
What was the expected behaviour?
it should be able to find the item using the text or id.
Was it tested on latest Detox?
Did your test throw out a timeout?
Help us reproduce this issue!
let address = element( by .id("location_heading") .and(by.text("Coaching Center")) );
In what environment did this happen?
Detox version: 20.13.2 React Native version: 0.67 Has Fabric (React Native's new rendering system) enabled: No Node version: v21.1.0 Device model: Pixel 4 emulator Android version: android 13 Test-runner (select one): jest
Detox logs
Detox logs
``` Test Failed: No views in hierarchy found matching: View at index #0, of those matching MATCHER((view.getTag() is "location_heading" and view has effective visibilityDevice logs
Device logs
``` paste your device.log here! ```More data, please!
have tried few variations on matchers by using type instead of id, chaining multiple matches and even tried with ancestor to find the parent listview and the child item but none of them seems to work.