- 启动Appium-GUI 点击 启动服务器
- 启动模拟器Genymotion
3. 在命令行窗口adb devices 查看模拟器IP
- 打开pycharm编写简单脚本如下
点击查看代码
from appium import webdriver
#import unittest
desired_caps={}
desired_caps['platformName']='Android'
desired_caps['deviceName']='192.168.29.102:5555'
desired_caps['platforVersion']='5.1.1'
desired_caps['appPackage']='com.android.calculator2'
desired_caps['appActivity']='com.android.calculator2.Calculator'
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
#driver.find_element_by_id('com.android.calculator2:id/del').click()
driver.find_element_by_android_uiautomator('text("7")').click()
driver.find_element_by_android_uiautomator('text("+")').click()
driver.find_element_by_android_uiautomator('text("9")').click()
driver.find_element_by_android_uiautomator('text("=")').click()
s=driver.find_element_by_id('com.android.calculator2:id/result').text
assert s=='16'
if s=='16':
print("计算结果正确")
- 运行脚本观察模拟器变化
- 查看控制台运行情况