打开Android模拟器上的计算器程序,并做一个简单的加法计算,先看自动化运行的效果图
python脚本代码如下
#coding=utf-8
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'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.find_element_by_name("1").click()
driver.find_element_by_name("+").click()
driver.find_element_by_name("2").click()
driver.find_element_by_name("=").click()
driver.quit()