Dynamic ID locator

How can I create a dynamic element? I have a dropdown that has many different years in it so I want to be able to find 2022, 2021, 2020, etc. with one element.

I want to do something like this:

[MobileFindsByAll(Android = true)]
[FindsByAndroidUIAutomator(XPath = “//android.widget.TextView[@text=‘2021’]”)]
public IWebElement YearDropdownElement;

but instead of 2021 every time, I want to be able to pass in different years. How do I do that? I tried passing it in via the constructor, but no luck with that.

It depends on your app and how the dropdown looks like…
Do you need to scroll the dropdown to find your element or not?

Do you want to catch a couple specific elements into a list or only one?