Hi all,
I’m trying to automate a third party app, and many times you have no IDs or other than xpath with the field Text. I mean, you have to reach the element by a text that changes depending on the language. For example:
New
Nuevo
Nuovo
So, you have to write 3 locators each time you need to reach by text:
public final String EN_TXT = "New";
public final String ES_TXT = "Nuevo";
public final String IT_TXT = "Nuovo";
@HowToUseLocators(androidAutomation = ALL_POSSIBLE)
@AndroidFindBy(xpath = ("//*[contains(text(), 'EN_TXT')]"))
@AndroidFindBy(xpath = ("//*[contains(text(), 'ES_TXT')]"))
@AndroidFindBy(xpath = ("//*[contains(text(), 'IT_TXT')]"))
MobileElement someElement;
Doing something like this is not possible because of Java annotations nature now allowing to use Variable values on Runtime:
@AndroidFindBy(xpath = ("//*[contains(text(), '" + someValueFromPropertiesFileDependingOnSelectedLanguage + "')]"))
MobileElement someElement;
So, the question is… how do you do it in a simple way? Do I have to write a locator strategy for every language? I found 2 solutions online but I think (hope) should be a easy way
https://medium.com/@harshitj.qa/localization-testing-with-appium-grid-ef7dadb09fa2
https://webelement.click/en/parameterized_findby_annotation_in_selenium_page_object_java
Thanks in advance and regards