自动化测试|Appium环境搭建 | App自动化测试

关联阅读:

移动端自动化测试 | Appium环境搭建

移动端自动化测试Appium环境搭建之 | 安装Android开发环境

移动端自动化测试Appium环境搭建 | 安装Android模拟器


安装 python-client

其实,python-client 的项目名称叫:Appium-Python-Client。

推荐pip安装:

(venv) λ pip install Appium-Python-ClientCollecting Appium-Python-Client
  Using cached Appium-Python-Client-0.24.tar.gz
Requirement already satisfied: selenium>=2.47.0 in d:\pyflask\venv\lib\site-packages (from Appium-Python-Client)
Building wheels for collected packages: Appium-Python-Client
  Running setup.py bdist_wheel for Appium-Python-Client ... done  Stored in directory: C:\Users\fnngj\AppData\Local\pip\Cache\wheels\2e\cf\10\0e3f177c9869147b16584d402f79d9007df1139105ea3ecc2c

Successfully built Appium-Python-ClientInstalling collected packages: Appium-Python-ClientSuccessfully installed Appium-Python-Client-0.24
运行第一个Appium测试

  • 第一步,启动Android模拟器。

  • 第二步,启动 Appium Server。

点击右上角 三角 按钮,注意Appium的启动日志。

> Launching Appium server with command: D:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> 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":"23","automationName":"Appium"}
> info: Console LogLevel: debug

Appium在启动时默认占用本机的4723端口,即:127.0.0.1:4723

  • 第三步,编写 appnium 测试脚本。

#coding=utf-8from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'desired_caps['platformVersion'] = '6.0'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()

运行上面的脚本,你将会看到 Android 模拟器如下运行界面:


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值