HenriJ
HenriJ

Reputation: 23

Xamarin UiTest binding android:id?

I'm working on implementing Xamarin automated User interface tests to an application (i haven't made) for an internship. One of the ways of accessing the elements visible on the screen is to access them through their ID (android: id in Android to be precise).

So the idea is that whoever made the application in Visual Studio created a template (in .axml) for a certain element and I added an android: id to this template but every element that uses this template have the same android: id so I can't access a particular element simply.

Is there any way to bind that android: id programmatically so every element would have different id?

Upvotes: 2

Views: 315

Answers (1)

lowleetak
lowleetak

Reputation: 1382

Using AppQuery.Marked, you can query using id, contentDescription or text. I personally use ContentDescription to get the view. Using ContentDescription I can easily assign the unique ID for a view programmatically.

view.ContentDescription = "test-id";

Upvotes: 1

Related Questions