appium 使用
安装教程:
https://pan.baidu.com/s/1C-WB6XREIE0YHaZJeujf4g
使用步骤:
1、手机用数据线连接电脑
2、选择文件夹方式连接
3、手机打开usb调试并允许
4、电脑命令行查看是否连接成功,>adb devices 出现
List of devices attached
f431d9 device
说明连接成功
5、打开appium桌面版
点击
start server 。。
出现
[Appium] Welcome to Appium v1.10.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
说明连接成功
6、手机打开一个app
7、查看打开的app 包名
adb shell dumpsys window windows | findstr "Current"
或
adb shell dumpsys window w |findstr \/ |findstr name=
mSurface=Surface(name=com.tll.wireless/com.tmall.wireless.maintab.module.TMMainTabActivity)
com.tll.wireless 就是的
根据appPackage包名查看appActivity
adb shell monkey -p com.android.jinvovocni -v -v -v 1
元素定位技巧:https://www.jianshu.com/p/efe9dcf8bbaf
8、写代码走起吧
# coding=utf-8
from appium import webdriver
import time
desired_caps = {}
# 设备信息
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.1.0'
desired_caps['deviceName'] = '18-A01'
# app信息
desired_caps['appPackage'] = 'com.tll.wireless'
desired_caps['appActivity'] = '.splash.TMSplashActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
time.sleep(5)
# result = driver.page_source
# print(result)
# print('-----', type(result))
# time.sleep(2)
xpath_class = "//*[contains(@content-desc,'分类')]"
driver.find_element_by_xpath(xpath_class).click()
time.sleep(10)

浙公网安备 33010602011771号