Inês
Inês

Reputation: 982

How to findObject in UiAutomator using position on screen (bounds)

I want to use device.findObject() to find an object in my screen, which requires a UiSelector. So far so good.

The problem is that I have several items only distinguishable by their position on the screen, e.g., in the messaging application all the Avatars have the same properties, except for their position in the screen.

How can I specify this?

I thought of:

Do you have any sugestions/solutions?

Thanks.

Upvotes: 3

Views: 6180

Answers (1)

Allen Hair
Allen Hair

Reputation: 1050

It's not a great solution, but you could use UiDevice.findObjects(..) to return all of them. Then use getVisibleBounds() or getVisibleCenter() to check the coordinates.

Upvotes: 5

Related Questions