結構如下:
String UiSelector="new UiSelector().className(\"android.widget.RelativeLayout\").childSelector(new UiSelector().className(\"android.widget.TextView\").text(\"Test郵件123xfm8c1o5\"))"; String xx=driver.findElementByAndroidUIAutomator(UiSelector).getText(); System.out.print("xx="+xx+"\n");
打印的是:Test222郵件123xfm8c1o5,也就是index為2的那個TextView節點。
問題:如何根據text是指定值的節點獲取它的兄弟節點?
比如根據text值是Test郵件123xfm8c1o5的那個節點獲取它的兄弟節點(index是0的那個textView)嘗試:
driver.findElementsByAndroidUIAutomator(UiSelector+".fromParent(\"android.widget.RelativeLayout\").childSelector(new UiSelector().className(\"android.widget.TextView\").text(\"xfm8c1o5_1@qa186.cn\"))" );
報錯:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
轉載文章時務必注明原作者及原始鏈接,並注明「發表於 TesterHome 」,並不得對作品進行修改。
- 請注意單詞拼寫,以及中英文排版,參考此頁
- 支持 Markdown 格式, **粗體**、~~刪除線~~、
`單行代碼`
, 更多語法請見這里 Markdown 語法 - 支持表情,使用方法請點擊☺
- 上傳圖片, 支持拖拽和剪切板黏貼上傳, 格式限制 - jpg, png, gif
- 發布框支持本地存儲功能,會在內容變更時保存,「提交」按鈕點擊時清空