【问题标题】:Unable to identify element in IOS无法识别 IOS 中的元素
【发布时间】:2018-07-11 22:26:07
【问题描述】:

我一直在尝试使用 Appium 从 IOS 中单击附加的突出显示(红色箭头)图标,但不断收到超时异常。仅针对表中的“193930 Copy 1”记录需要此单击。有什么帮助吗?

Appium: 1.6.2
XCode: 9.4
Tested in?: Native App
IOS: 11.4
Model: iPhone X

例外:-

org.openqa.selenium.TimeoutException:预期条件失败:等待 By.xpath 定位的元素的可见性:

尝试过的 Xpath 是:-

//XCUIElementTypeStaticText[@name='193930 Copy 1']/XCUIElementTypeButton[contains(@name, 'more')]

(//XCUIElementTypeStaticText[@name='193930 Copy 1'])/following-sibling::XCUIElementTypeButton[@name='more']

//XCUIElementTypeStaticText[@name='193930 Copy 1']/XCUIElementTypeButton[`name == "more"']

//XCUIElementTypeStaticText[contains(@name,'193930 Copy 1')]/following-sibling::XCUIElementTypeButton

//XCUIElementTypeStaticText[contains(@name,'193930 Copy 1')]/XC​​UIElementTypeButton

【问题讨论】:

  • 页面上是否有多个“更多”按钮?
  • 是的,表格包含记录列表,并且“更多”按钮与每条记录相关联。
  • 您的最后一个定位器在我看来是最正确的。将 xpath 添加到本文的标签列表中,以便对 xpath 更有经验的人可以发表评论并可能提供更好的解决方案。我会为你做,但需要同行的批准,如果你作为原始海报做,它会通过。

标签: appium appium-ios


【解决方案1】:

我试图在我们自己的应用程序中复制您遇到的问题,这就是我想出的并且对我有用(请注意我使用的是 Appium 版本 1.7.1,这可能会影响结果):

//XCUIElementTypeStaticText[@name='193930 Copy 1']/following-sibling::XCUIElementTypeButton

您不需要指定下一个元素的名称,因为您可以使用应用程序的结构。我认为您的尝试中出现的问题是您组合了错误的属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-25
    相关资源
    最近更新 更多