8.测试脚本
(1) 打开SDK Manager.exe ->打开 Android Virtual Device Manager->创建模拟器->Start
(2) 对模拟器中“计算器”进行加法操作
打开”python”->”IDLE”新建脚本
#coding=utf-8
from appium import webdriver
from appium.webdriver.mobilecommand import MobileCommand
import time
import os
desired_caps = {}
desired_caps[‘platformName‘] = ‘Android‘
desired_caps[‘platformVersion‘] = ‘4.4.2‘
desired_caps[‘deviceName‘] = ‘emulator-5554‘
desired_caps[‘appPackage‘] = ‘com.android.calculator2‘ #被测App的包名
desired_caps[‘appActivity‘] = ‘.Calculator‘ #启动时的Activity
desired_caps[‘unicodeKeyboard‘] = True
desired_caps[‘resetKeyboard‘] = True
desired_caps[‘newCommandTimeout‘] = 7200
driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)
driver.find_element_by_id("com.android.calculator2:id/digit2").click()
driver.find_element_by_id("com.android.calculator2:id/plus").click()
driver.find_element_by_id("com.android.calculator2:id/digit4").click()
driver.find_element_by_id("com.android.calculator2:id/equal").click()
driver.quit()
(3)打开->Android Settings进行设置
(4)启动Appium-server->运行脚本