【问题标题】:How to create Xpath with the help of UIAutomator for android App?如何在 UIAutomator for android App 的帮助下创建 Xpath?
【发布时间】:2014-06-18 08:45:25
【问题描述】:

如何借助 UIAutomator for android App 创建 Xpath?

任何指南的链接都会很有帮助。 目前 UIautomator 不提供 Xpath。我想知道创建 xpath 的步骤。

【问题讨论】:

标签: android appium


【解决方案1】:

好的,所以我推荐阅读这篇文章:http://www.w3schools.com/XPath/xpath_syntax.asp

但是如果你想找到一个带有“hello world”文本的TextView,你可以使用这个xpath:

//android.widget.TextView[@text='hello world']

// 表示获取任意元素

//android.widget.TextView 表示获取类 android.Widget.TextView 的任何元素

//android.widget.TextView[@text='hello world'] 表示获取类的任何元素 android.Widget.TextView 属性“text”等于“hello world”

我希望这个解释会有所帮助。如果您想更好地理解,请阅读该文章

【讨论】:

    【解决方案2】:

    您可以从 R.class 中的 ID 访问元素。例如:

    EditText editText = (EditText) getSolo().getView(R.id.note);
    

    您可以在 UIautomator 的 resource-id 列中找到它。您也可以通过文本等点击元素。

    如果您正在测试网络应用程序,您可以在 chrome 中模拟视图并从那里获取 x-path。转到开发者工具 -> 仿真并选择您需要的设备和代理。

    我使用的是 Robotium 框架

    如果你不知道如何构建 xpath,这里有很好的教程http://www.w3schools.com/XPath/

    【讨论】:

      【解决方案3】:

      如果您使用的是 appium 模式,最好使用 appium 检查器(appium 桌面应用程序),否则如果在 selendroid 模式下使用 selendroid 检查器 - http://selendroid.io/inspector.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-22
        • 2011-01-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-23
        相关资源
        最近更新 更多