【问题标题】:How to find an element inside a tablelayout using xpath in appium for android如何在 appium for android 中使用 xpath 在 tablelayout 中查找元素
【发布时间】: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


    【解决方案1】:

    尝试使用:

    WebElement username=driver.findElement(By.xpath("//TableLayout[@index='1']/TableRow[@index='0']/EditText[@index='0']"));
    

    【讨论】:

      猜你喜欢
      • 2020-04-25
      • 1970-01-01
      • 2015-05-03
      • 2017-09-14
      • 2020-11-25
      • 2016-01-21
      • 2020-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多