• 【基础】查找元素篇(二)


    通过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")");

  • 相关阅读:
    转:PCIe基础知识
    转:HDMI介绍与流程
    Java EJB JBoss
    冒泡排序
    多线程
    快排
    Talk is cheap,show me the code
    oracle union
    Oracle 【to_number】【instr】
    DB 【ACID】
  • 原文地址:https://www.cnblogs.com/Jourly/p/8080206.html
Copyright © 2020-2023  润新知