安装appium android-sdk
然后连接手机 查看手机上的文字或者其他内容
先要引入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from appium import webdriver
初始化driver
desired_caps['deviceName'] = '设备名' # 手机设备名称,adb devices
desired_caps['platformVersion'] = '7.0' # 手机版本,在手机中:设置--关于手机
desired_caps['platformName'] = 'Android'
desired_caps['appPackage'] = appPackage #通过adb shell dumpsys window windows | findstr mFocusedApp查看
desired_caps['appActivity'] = appActivity #通过adb shell dumpsys window windows | findstr mFocusedApp查看
desired_caps["unicodeKeyboard"] = True
desired_caps["resetKeyboard"] = True
desired_caps["noReset"] = True
desired_caps["newCommandTimeout"] = 6000
desired_caps['recreateChromeDriverSessions'] = True
desired_caps['automationName'] = 'uiautomator2'
desired_caps['recreateChromeDriverSessions'] = True
driver= webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
查找元素主要是通过find_element_by_android_uiautomator find_element_by_id find_element_by_class_name
设置等待使用WebDriverWait(driver, 1).until(lambda x:x.find_element_by_class_name("android.widget.RelativeLayout"))
python 抓取app数据
最新推荐文章于 2024-08-12 17:05:35 发布