appium 环境安装指引

1、安装Appium-Python-Client

Pip install Appium-Python-Client

2、安装nodejs

https://nodejs.org/

安装成功验证:node -v  、npm -v

 

3、安装appium

Npm install -g appium

安装成功验证:appium -v

4、安装JAVA环境

Java环境分jdkjre

配置环境变量

 

 

验证java是否安装成功在命令行分别输入:java  javac

 

5、安装appium-desktop

V1.15.1比较稳定

https://github.com/appium/appium-desktop/releases

6、通过如下地址安装所需要的Android SDK

https://www.androiddevtools.cn/

 

 

7、启动appium

1) 可通过命令行输入appium

2) 直接启动appium.exe

 

 

 8、启动模拟器,点击AVD Manager.exe

 

 

9、执行脚本,验证环境是否可正常跑通

from appium import webdriver
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'Android Emulator'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'
desired_caps['automationName'] = 'UiAutomator1'

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

 

报错解答:

1、Encountered internal error running command: Error: Unable to find an active device or emulator with OS 4.2. The following are available: emulator-5554 (4.4.2)

答:平台版本对不上,把desired_caps['platformVersion'] = '4.2'改成desired_caps['platformVersion'] = '4.4.2'

2、Encountered internal error running command: Error: UIAutomator2 is only supported since Android 5.0 (Lollipop). You could still use other supported backends in order to automate older Android versions.

答:Android版本低于5.0,所以需要设置#desired_caps['automationName'] = 'UiAutomator1'

posted @ 2020-10-10 19:44  啊洽  阅读(273)  评论(0编辑  收藏  举报