初级篇
appium GUI(Graphical User Interface),安装步骤如下:
- jdk 安装,及配置环境变量
path ****\bin;classpath: *****\lib - Android SDK 及配置ANDROID_HOME环境变量,ANDROID_HOME: ***\sdk; path添加;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform_tools; 然后打开cmd
android -h
验证是否正确,第一次配置好后,appium 一直报错adb不能使用,然后我重启电脑OK了。 - 安装node.js,下载安装即可
- appium.io 下载appiumForWindows,解压即可
- 还要安装appium client,java的用java-client,去下载安装,我用的python,所以安装的python-client,
git clone git@github.com:appium/python-client.git
cd python-client
python setup.py install
没有安装 ant maven git 等等,等用到了再安装吧
然后启动appium server,
> Starting Node Server
> info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"}
> info: Console LogLevel: debug
启动成功。
启动server也可以cmd到appium目录执行
node.exe node_modules\appium\bin\appium.js
启动appium
运行一个Python的demo就可以看到手机上的变化及server的日志也出来了
demo
import os
import unittest
from time import sleep
from appium 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)
)
class ContactsAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.3'
desired_caps['deviceName'] = 'emulator-5554'
desired_caps['app'] = PATH('D:\\python\\py_workspace\\Aimsi.apk')
desired_caps['appPackage'] = 'com.example.aimsi'
desired_caps['appActivity'] = '.MainActivity'
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
def tearDown(self):
self.driver.quit()
def test_add_contacts(self):
el = self.driver.find_element_by_name("IMSI_IMEI")
el.click()
buttons=self.driver.find_elements_by_class_name("android.widget.Button")
print buttons
buttons[0].click
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ContactsAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)