【问题标题】:Element not found by identifier in AppiumAppium中的标识符未找到元素
【发布时间】:2017-03-30 23:21:47
【问题描述】:

我收到以下错误:

ValueError: Element locator 'identifier=id/edittext1' did not match any elements.

有一个 id 为 edittext1 的元素但无法识别!

【问题讨论】:

  • 尝试使用 xpath 进行元素定位
  • 您是否尝试过使用 cssselector 或 xpath 等其他定位器?
  • @sai 我认为你面临的语法问题,你能把你的代码贴在这里,以便我可以帮助你

标签: android appium


【解决方案1】:

我也遇到过类似的问题。

我使用 xpath 进行元素定位。

下面是示例xpath

,供您参考
Input Text  xpath=/hierarchy[@rotation="0"]/android.widget.FrameLayout[@index="0"]/android.widget.LinearLayout[@index="0"]/android.widget.FrameLayout[@index="0"]/android.widget.RelativeLayout[@index="0"]/android.widget.EditText[@index="0"]

【讨论】:

    【解决方案2】:

    尝试使用其他定位器,我曾经遇到过同样的问题。但是使用 CssSelector 可以正常工作。

    点击按钮示例:

    WebElement element1 = driver.findElement(By.cssSelector("div[ng-click^='actionname']"));
    element1.click();
    

    【讨论】:

    • PS:这个例子只是为了让你了解cssSelector是如何工作的!
    • CSS 与原生移动应用有何关系?
    • 我将它用于混合应用程序,很抱歉我不确定是否可以用于本机应用程序。
    猜你喜欢
    • 2019-04-24
    • 2019-09-24
    • 1970-01-01
    • 2016-07-25
    • 2014-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多