【发布时间】:2014-10-27 18:11:38
【问题描述】:
如何在 appium for android 中使用 xpath 在 tablelayout 中查找元素。我尝试了以下语法
WebElement username=driver.findElement(By.xpath("//android.widget.TableLayout[@index='1']//android.widget.TableRow[@index='0']/android.widget.EditText[@index='0']"));
username.sendKeys("sampletext");
但我收到以下异常。
"org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters."
当我尝试以下方法时
WebElement username=driver.findElement(By.xpath("//android.widget.EditText[@index='0']"));
它工作正常。当我尝试添加父级后跟子级时出现问题。
1.如何使用 for 循环访问表格布局的所有子项?
2.如何使用 xpath 找到一个孩子跟着父母。请帮助
【问题讨论】:
标签: java android selenium xpath appium