1、下载AppiumForWindows-1.3.4.1.zip,下载地址https://bitbucket.org/appium/appium.app/downloads/,下载完成后解压
2、将截图中文件的路径添加到path环境变量里边
3、在CMD运行appium-doctor,无报错信息即安装成功
4、开启Appium
5、创建测试应用,确定包名和Activity的名称
5、ANDROID连接至电脑
6、CMD输入adb devices,查看连接的手机的deviceName,备用,代码需用到
7、在eclipse中run 第5步创建的应用,该应用将被安装到手机上
8、运行以下代码
#coding:utf-8
import os
import unittest
from selenium import webdriver
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
desired_caps = {}
desired_caps['deviceName'] = '5e503562' #adb devices查到的设备名
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['appPackage'] = 'com.example.bus01' #被测App的包名
desired_caps['appActivity'] = 'com.example.bus01.MainActivity' #启动时的Activity
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = driver.find_element_by_name("Button")
el.click()
print u"成功了"
driver.quit()
9、在手机上看到自动打开Bus01应用点击button按钮即成功