zoukankan      html  css  js  c++  java
  • 【基础】查找元素篇(二)

    通过uiautomatorviewer工具来定位

    一、通过ID(resource-id)

    示例:

    driver.findElement(By.id("com.globalegrow.app.gearbest:id/show_shop_price"));

    driver.findElementById(id"com.globalegrow.app.gearbest:id/show_shop_price")

    二、通过className(class)

    示例:

    driver.findElement(By.className("android.widget.TextView"));

    driver.findElementByClassName("android.widget.TextView");

    这个一般用复数来获取,然后用List来取值。

    三、通过xpath

    driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'Cart')]"));

    android.widget.TextView 为class

    四、通过AccessibilityId(content-desc)

    driver.findElementByAccessibilityId("test");

    五、通过AndroidUIAutomator

    5.1 text
    driver.findElementByAndroidUIAutomator("new UiSelector().text("more+")");
    5.2 textContains
    driver.findElementByAndroidUIAutomator("new UiSelector().textContains("more")");
    5.3 index,多个
    driver.findElementByAndroidUIAutomator("new UiSelector().textContains("more").index(1)");
    5.4 包名,id
    driver.findElementByAndroidUIAutomator("new UiSelector().className("android.widget.TextView").resourceId("com.globalegrow.app.gearbest:id/more_deals_tv")");

    5.5 desc

    driver.findElementByAndroidUIAutomator("new UiSelector().description("test")");

  • 相关阅读:
    jquery.md5
    LoginPasswordHelp
    RSA(非对称加密算法、公钥加密算法)
    Swiper 3.4.1
    layer web 弹窗
    操作系统
    查看命令帮助
    软件卸载
    重定向命令
    终端命令格式的组成
  • 原文地址:https://www.cnblogs.com/Jourly/p/8080206.html
Copyright © 2011-2022 走看看