Python+Appium自动化测试-1:给真机自动安装apk

  1. 下载Appium Desktop版本,安装后使用默认配置运行;
    https://github.com/appium/appium-desktop/releases

  2. 安装appium python客户端

pip install Appium-Python-Client
  1. 使用USB连接手机到电脑,查看设备是否已连接
adb devices

在这里插入图片描述
4. 代码实现

# -*- coding: utf-8 -*-
# @Author   : cjn
# @FILE     : installAPK.py
# @Time     : 2020/4/13 15:58
from appium import webdriver
import os
Propath =  os.path.split(os.path.realpath(__file__))[0]

appPath = os.path.join(Propath, "file", "6edu1.0.0.23.apk")   #apk目录

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9'    #手机系统版本
desired_caps['deviceName'] = 'Honor9'   #手机设备名称 
desired_caps['app'] = appPath

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

driver.quit()

你可能感兴趣的:(Appium)