1. charles
  • 重发
    笔》

  • 修改响应内容
    Map Local/ Map Remote

  1. appium
    通过inspect或者python调试
  • 定位元素
from appium import webdriver
from selenium.webdriver.common.by import By

server = 'http://localhost:4723/wd/hub'
desired_capabilities = {
	"platformName": "Android",
	"appium--使用:deviceName": "127.0.0.1:62001",
	"appium--使用:appPackage": "com.goldze.mvvmhabit",
	"appium--使用:appActivity": ".ui.MainActivity",
	"appium--使用:noReset": "true",
	"appium--使用:platformVersion": "7.1.2"
}
driver = webdriver.Remote(server, desired_capabilities)
'''根据id定位 resource-id'''
from appium.webdriver.common.mobileby import MobileBy
driver.find_element(MobileBy.ID, "")

'''根据className定位 class'''
driver.find_element(MobileBy.CLASS_NAME, "")

'''xpath text唯一'''
driver.find_element(by=By.XPATH, value="//*[@text='通讯录']")

'''xpath resource id唯一'''
driver.find_element(by=By.XPATH, value='//*[@resource-id="com.tencent.wework:id/b09"]')
'''xpath id+text'''
driver.find_element(by=By.XPATH, value='//*[@resource-id="com.tencent.wework:id/e0y"][@text="通讯录"]')
'''xpath class唯一'''
driver.find_element(by=By.XPATH, value="//android.widget.EditText")
driver.find_element(by=By.XPATH, value="//*[@class='android.widget.EditText']")

'''content-desc'''
# 选中节点-content-desc
from appium.webdriver.common.appiumby import AppiumBy
driver.find_element(AppiumBy.ACCESSIBILITY_ID, value='Animation')
# 精确匹配
driver.find_element(by=By.XPATH, value="//*[contains(@text,'通讯录')]")
# 模糊匹配
driver.find_element(by=By.XPATH, value="//*[contains(@content-desc,'通')]")
posted on 2024-05-04 13:47  HelloJacker  阅读(4)  评论(0编辑  收藏  举报