Im running APPIUM Automation for IOS.
I set element to click on it like this :
SerchField = (MobileElement)driver.findElement(By.xpath("//XCUIElementTypeCell[contains(@name,'"+ContactName+"')]"));
ContactName = "abcdef"
But in the mobile screen the contact name show is "Abcdef" so i get an error message that element cannot be found
how can i change the xpath so he will found the element even if the string start with "A" or "a" ?
Thanks !
I assume you're using Java.
Using XPATH logical or
Here @name
shoud match any of abcdef
, Abcdef
.
ContactName = "abcdef";
String contactNameCapitalized = ContactName.substring(0, 1).toUpperCase() + ContactName.substring(1);
String serchFieldxpath = "//XCUIElementTypeCell[(contains(@name,'"+ContactName+"')) or (contains(@name,'"+contactNameCapitalized+"'))]";
SerchField = (MobileElement)driver.findElement(By.xpath(serchFieldxpath));
Using XPATH translate
This translates all upper-case characters to lower-case. ContactName
also should be lowercase.
ContactName = "abcdef";
SerchField = (MobileElement)driver.findElement(By.xpath("//XCUIElementTypeCell[contains(translate(@name,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'"+ContactName+"')]"));