appium 下 python 脚本自动化测试iOS APP 实例

环境:Mac,Xcode, appium python
本文基于appium 环境搭建成功后。如何使用python 编写脚本测试iOS APP

1.下载python-client https://github.com/appium/python-client
2.在终端 打开到已经下载的文件目录下执行 python setup.py install
3. 打开apppium 桌面版。点击 start session (host,port 不变,默认host 0.0.0.0 port: 4723)
4. 创建一个demo.py 文件
5. 代码如下:
‘import unittest
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
desired_caps = {}
desired_caps[‘platformName’] = ‘iOS’
desired_caps[‘platformVersion’] = ‘10.3’
desired_caps[‘deviceName’] = ‘设备名’
desired_caps[‘bundleId’] = ‘项目的bundleId’
desired_caps[‘udid’] = ‘测试手机的udid’
desired_caps[‘app’] = ‘/Users/xiaoMing/Desktop/testDemoipa/testDemo.ipa’ // 必须先将项目打包ipa,此处传入ipa 路径
driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)
el = driver.find_element_by_accessibility_id(‘Button’) // Button 是通过appium 采集到的对应按钮的id
action = TouchAction(driver)
action.tap(el).perform() // 执行点击事件

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值