首页 > 其他分享 >new UiSelector()之text定位用法

new UiSelector()之text定位用法

时间:2022-08-18 18:23:43浏览次数:46  
标签:定位 UiSelector text new android 文本

来源:https://www.csdn.net/tags/OtDaYgxsNTExNDItYmxvZwO0O0OO0O0O.html

 

  • driver.find_element_by_android_uiautomator("表达式")
  • 注:外层要用单引号,内层的字符串用双引号,因为本来就是 Java,Java 双引号才表示字符串
  • 通过文本定位
    • new UiSelector().text("text文本")
  • 通过 textContains 模糊匹配
    • new UiSelector().textContains("text文本")
  • 通过某个文本开头匹配
    • new UiSelector().textStartWith("text文本")
  • 正则表达式匹配
    • new UiSelector().textMatches("text文本")
  • 组合定位
    • 比如 id 与 text 的属性组合:driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/login_account").text("我的")')
  • 父子关系定位:childSelector,先定位到父类,再用 childSelector 来定位子类
    • driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/login_account").childSelector(text("股票"))')
  • 兄弟定位:fromParent
    • driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.xueqiu.android:id/login_account").fromParent(text("股票"))'

标签:定位,UiSelector,text,new,android,文本
From: https://www.cnblogs.com/tianyumuhe/p/16599707.html

相关文章