I need to scroll and select the element with text/description using UiAutomator
Example: Consider Android Settings Application
if Text need to find is Sound & Notification, i need to find the element with text contains Sound,Notification words. So I went to regex to find the Element
UiAutomator Code:
Not able to fineElement with below uiautomator code
new UiScrollable(new UiSelector().resourceIdMatches("^.scrollableViewResoruceId.$")).scrollIntoView(new UiSelector().textMatches("^(?i)(?=.*\bsound\b)(?=.*\bnotification\b).*$").instance(0));
Note: resourceId may change based on OS version
Im able to find the Element without scrolling using below code
new UiSelector().textMatches("^(?i)(?=.*\bsound\b)(?=.*\bnotification\b).*$").instance(0);
When I checked in the UiSelector Source code in the below link
UiSelector class using Java Pattern Class for regex
So I tried to check regex using Pattern and Matcher Class
String textToFind=Sound & Notification
Pattern pattern=Pattern.compile("^(?i)(?=.*\bsound\b)(?=.*\bnotification\b).*$");
Matcher matcher=pattern.matcher(textToFind);
matcher.find();
System.out.println(matcher.group());
Matcher class find the text
Can anyone help me on this?