[英]How to create Xpath with the help of UIAutomator for android App?
如何借助UIAutomator for Android App創建Xpath?
鏈接到任何指南將非常有幫助。 當前,UIautomator不提供Xpath。 我想知道創建xpath的步驟。
好的,所以我建議閱讀這篇文章: 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']
意味着獲取屬性為“ text”等於“ hello world”的android.Widget.TextView
類的任何元素
我希望這種解釋會有所幫助。 如果您想更好地理解,請閱讀該文章
您可以在R.class中訪問元素的ID。 例如:
EditText editText = (EditText) getSolo().getView(R.id.note);
您可以在UIautomator的resource-id列中找到它。 您也可以單擊文本等元素。
如果要測試Web應用程序,則可以在chrome中模擬視圖並從中獲取x路徑。 轉到開發人員工具->仿真,然后選擇所需的設備和代理。
我正在使用Robotium框架
如果您不知道如何構建xpath,可以參考http://www.w3schools.com/XPath/
如果您使用的是appium模式,最好使用appium inspector(appium桌面應用程序),否則,如果在selendroid模式下,請使用selendroid inspector- http: //selendroid.io/inspector.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.