I have multiple elements on a screen. See the photo attached
Each appointment can have the same date but different types(billable, non-billable), times, etc. Date, time, type, and other fields have the same class as a TextView, or the same id such as appointment_date or appointment_type.
Question: how can I click on specific appointment by choosing two textview values out of 6?
Hi. not sure I understood your question properly but in anyway, you need to find a common locator(id, classChain etc…) for the appointments (you can ask your iOS developers to provide you with ids from their mobile code - accessibilityIdentifier in swift).
then you can find all elements(with .findElements(byLocator)) by a common locator (specific for them so you won’t find something else on the screen) - put them into a List and loop through them until you find an element with your desired date/time or a specific combination as your wish. - it might be time consuming if you have a lot of elements.
another way, is to use a complex xpath locator to define a specific element by its value/a combination of them. you can get to your specific TestView and with xpath go “backward” to its parents - not recommended but sometimes there is not much choice…
but I bet you can get to the element/s without asking for specific ids, try to be creative
you should execute in loop:
List<WebElement> calendarItems; // find item in way you know
String typeTxt, timeTxt;
foreach(WebElement item : calendarItems) {
typeTxt = item.findElement(AppiumBy.id("yourTypeElementID")).getText();
timeTxt = item.findElement(AppiumBy.id("yourTimeElementID")).getText();
if (typeTxt.equals("YourTypeNeeded") && timeTxt.equals("YourTimeNeeded")) {
tap(item); // item found now tap on it in any way you know
break;
}
}