3

I have a list of contacts which is scrollable. I want to get all contacts starting with +880 while scrolling. How can I use regex here? Here is my code

     ui_str = 'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "+880")'
     current_group_members = admin_device.driver.find_elements_by_android_uiautomator(ui_str)

I've also resource id of each element com.test.communicator:id/phoneNumberTxt. Can I get all elements with this id? I've tried to use find_elements_by_id but It gets only visible items. I need all elements in the list.

Shahrear Bin Amin
  • 1,075
  • 13
  • 31

1 Answers1

0

You could search through the children by selecting those matching a text regex. See UiSelector.textMatches(...) for getting UiAutomator to use regex:

Per Javadoc:

Set the search criteria to match the visible text displayed in a layout element, using a regular expression. The text in the widget must match exactly with the string in your input argument. https://developer.android.com/reference/androidx/test/uiautomator/UiSelector#textmatches

Scott Merritt
  • 1,284
  • 2
  • 13
  • 24