Can anyone help me to write xpath in appium 1.7 for iOS..
If two class having same name
driver.findElementByClassName("TextField").sendKeys("abc");
driver.findElementByClassName("TextField").sendKeys("1234");
In any case use className
is not reliable search strategy as its not a unique.
I usually suggest following rules:
AccessibilityId
for most of elements used in automation tests (talk with developers if they agree to fix this)Xpath
with relation to other elements that have AccessibilityId
or more unique className
As a temporary solution you can do this:
List<WebElement> textfields = driver.findElementsByClassName("TextField");
textFields.get(0).sendKeys("abc");
textFields.get(1).sendKeys("1234");
since you didn't provide your page source, better print it out with driver.getPageSource()
and think of good XPath that you put in:
List<WebElement> textfields = driver.findElementsByXpath(<your xpath>);