Appium入门(5)__ Appium测试用例(1)

步骤为:启动AVD、启动Appium、写用例(python)、执行

一、启动Android模拟器

                 

二、启动Appium Server

双击appium图标启动,配置appium的Android Settings,将PlatformVersion对应AVD配置中的target;Device Name对应AVD中的AVD Name

General Settings保持默认就好

点击右上角启动Appium,默认占用本机的4723端口,即:127.0.0.1:4723

 三、编写python代码 

在Notepad或者python编辑器中编写代码

#coding=utf-8  
from appium import webdriver  
  
desired_caps = {}  
desired_caps['platformName'] = 'Android'  
desired_caps['platformVersion'] = '5.0.1'  
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("5").click()  
  
driver.find_element_by_name("9").click()  
  
driver.find_element_by_name("delete").click()  
  
driver.find_element_by_name("9").click()  
  
driver.find_element_by_name("5").click()  
  
driver.find_element_by_name("+").click()  
  
driver.find_element_by_name("6").click()  
  
driver.find_element_by_name("=").click()  
  
driver.quit() 

四、运行

cmd中输入 python d:mk est.py,运行的应用是android自带的计算器。

原文地址:https://www.cnblogs.com/happy-xiaoxiao/p/8365439.html