【问题标题】:Not able to locate element in appium by using xpath ends-with for iOS app created using react native对于使用 react native 创建的 iOS 应用程序,无法使用 xpath 结尾在 appium 中定位元素
【发布时间】:2020-05-02 23:09:26
【问题描述】:

我正在自动化使用本机反应制作的 iOS 应用程序的流程。

我可以正常通过 XPath 找到元素,但是在尝试使用 end-with 语法时,它无法找到元素。

我使用的是python语言,下面是我使用的sn-p代码示例: self.driver.find_element_by_xpath("//XCUIElementTypeOther[ends-with(@name, 'locatorValue')]")

我试图找到解决方案或示例语法来检查我是否做错了什么,但大多数时候我只获得了 Android 的示例,而且我使用的语法似乎对我来说是合适的理解。

对于使用 react native 制作的 iOS 应用程序,我不能使用以 xpath 结尾的限制,还是我在这里遗漏了什么?

请帮助我。

【问题讨论】:

    标签: appium appium-ios python-appium


    【解决方案1】:

    您可以简单地使用 iOS NSPredicate 表达式,例如, self.driver.find_element_by_ios_predicate("name ENDSWITH 'locatorValue'")

    这应该适合你。

    要了解有关 iOS 谓词的更多信息,请查看here

    【讨论】:

      【解决方案2】:

      正如上面评论中解释的iOSNsPredicateString可以这样使用

      self.driver.find_element_by_ios_predicate("type =='XCUIElementTypeOther' AND name ENDSWITH[c] 'locatorValue' AND enabled==1")
      

      【讨论】:

        猜你喜欢
        • 2017-05-07
        • 2014-07-27
        • 2018-03-15
        • 2017-10-11
        • 2019-12-18
        • 1970-01-01
        • 2023-04-01
        • 2016-10-25
        • 2021-02-11
        相关资源
        最近更新 更多