Is there a way to click an element without findElementsByClassName?

Now I’m doing this:

List els2 = getIOSDriver().findElementsByClassName(“XCUIElementTypeOther”);
String email = els2.get(31).getAttribute(“label”);

and findElementsByClassName is very slow. Is there a way to click on that element without searching for it?
It doesn’t have a static id so I can’t search by that. It changes depending on a user’s email.
(//XCUIElementTypeOther[@name="Email [email protected] "])[1]

Check if some parent of that element has an ID or has some specific type.
For example your “XCUIElementTypeOther”, has parent “XCUIElementTypeOther” with ID = “others_parent” - in this case you can do:

driver.findElement(By.id(“others_parent”).findElement(By.ClassName(“XCUIElementTypeOther”));

or if it has a specific type you can do:

driver.findElement(By.className(“XCUIElementTypeTable”).findElement(By.ClassName(“XCUIElementTypeOther”));

When you have a lot of elements on a screen with the same type, it takes a lot of resources to find a specific element (which makes sense) and is also very unsafe (in case your screen is dynamic and some other element get in between, then your element will not be on index = 31). Let the developers assign ID to that element, that would be a perfect scenario.

Maybe you can post a screenshot of hierarchy tree and we can have a look what is possible to do.

Unfortunately, every parent’s id is tied with email value.

Is there a way to search by part of the name for ios, would it be more efficient? Since there will always be "Email " in the xpath/id? (//XCUIElementTypeOther[@name="Email [email protected] "])[1]