MARK MARK - 1 month ago 13
Android Question

Find element in appium

How do I find an element in a linear layout which have a specific index, as obtain in the image I have this element android.widget.EditText, which has index 3. When I try to find it using the search parameter:


driver.FindElement(By.XPath("//android.widget.EditText[@index='3']")).SendKeys("123");


and I tried this as well

driver.FindElementByXPath("//*[@class='android.widget.EditText' and @index='3']").SendKeys("123");



I get this exception
{"An element could not be located on the page using the given search parameters."}



How can i select this element?

Answer

Since index is involved , i would suggest u to put the element identifier in a list and and get index and click. Try the below code

List<WebElement> list= driver.findElements(By.XPath("identifier"));
System.out.println("size of List= " + list.size());
        list.get(3).click();