senthil vel
senthil vel

Reputation: 71

How to find a element using BySelector Text with ignore case in espresso

Hi my app require a browser to select , so while opening my app it ask for a browser to be selected and for I that I am using

   UiDevice device = UiDevice.getInstance(getInstrumentation());
   device.wait(Until.findObjects(By.text("Chrome")),10000);
   device.findObject(By.text("Chrome")).click();

and to select next option Just once or Always , it verifies from device to device some device Shows "ALWAYS" text and some device shows "Always"

device.wait(Until.findObjects(By.text("ALWAYS")),4000); device.findObject(By.text("ALWAYS")).click();

is there a way to select the using By selector irrespective of the Text upper case or lower case (ignore casing)

Upvotes: 1

Views: 1862

Answers (1)

user2453382
user2453382

Reputation:

Use By.text(Pattern p).

Pattern patternToMatch = Pattern.compile("always", Pattern.CASE_INSENSITIVE);
device.wait(Until.findObjects(By.text(patternToMatch)),4000);

Upvotes: 2

Related Questions