1.安装:node.js -> appium
node.js 先安装node.js 。node.js官方网站:https://nodejs.org/
pip install Appium-Python-Client
2.demo
#coding=utf-8
from appium import webdriver
desired_caps = {}
desired_caps[‘platformName‘] = ‘Android‘
desired_caps[‘platformVersion‘] = ‘5.0.1‘
desired_caps[‘deviceName‘] = ‘Demo‘
desired_caps[‘appPackage‘] = ‘com.android.calculator2‘
desired_caps[‘appActivity‘] = ‘.Calculator‘
driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘;, desired_caps)
driver.find_element_by_name("1").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("delete").click()
driver.find_element_by_name("9").click()
driver.find_element_by_name("5").click()
driver.find_element_by_name("+").click()
driver.find_element_by_name("6").click()
driver.find_element_by_name("=").click()
driver.quit()
3.android模拟器启动不起来, Appium报错(android环境变量没有设置好)
运行Demo报错也是android环境没有设置好
ANDOID_HOME = C:\android
%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
4.android模拟器在AVD中不显示(android环境变量没有设置好)
ANDOID_SDK_HOME = C:\android
5.获取应用程序的包名
- adb shell pm list package -f
- adb shell pm list package -3 -f #获取第三方apk的包
- adb shell dumpsys window | findstr mCurrent #需要先打开应用程序
appium + python