How to handle the dynamic locators for Mobile objects?

Hi all,

I am testing the mobile application. I’m new here and trying to make the robust locators by my on own.

Now, I’m a stuck at one point where I have to make a locator for the widget object that contains a long string. So, I want to make a locator with having a small part of that text.

For your reference, below is the locator that I want to make:

Object name: android.view.View

Locator Strategy: Android UI Automator

Locator: new UiSelector().className("android.view.View").description("Do you want to see the Product tour again?")

But I want like this:

Locator: new UiSelector().className("android.view.View").description("Product tour")

I just want to check the Product tour instead to check the whole line - Do you want to see the Product tour again?.

Is there any way to handle this in locators?

Thanks in advance! :slightly_smiling_face:

How about using descriptionContains()?

I just used Bing’s Search Assistant to look it up. There are also:
description(), descriptionContains(), descriptionMatches(), and descriptionStartsWith()

Edit: using Bing search engine, highlight “UiSelector” and a Search icon appears. Click on it and a sidebar appears with, usually, a definition and web sites about your topic.


Yes! This is what I looking for. descriptionContains() works as intended.

Can you please share the query What you have searched that gives you these internal locator functions Or if you have any doc link about these locator functions then it will be good to have that.

Thanks a lot for the quick assistance. :star::blush:

1 Like