I just started using Appium recently for mobile app testing and have a question related to UI mapping.
I would like to assign frequently used elements in my app to variables at the beginning of my test script so I can just use the variable without typing out the locator each time I need to use the element in my testing.
e.g.
//Elements are not available yet
IOSElement settingButton = driver.findElement(By.name(“settings”));
IOSElement doneButton = driver.findElement(By.name(“Done”));
…
//Elements are now available
settingButton.click();
doneButton.click();
However, to my knowledge, the moment it is declared the findElement method will try to find the element and stop the test if it is not found.
The elements I would like to map might not be available at the time of declaration.
So my question is, how do I map the elements?
Thanks in advance.