自动化测试之ios测试脚本

一、连接手机,安装App

首先要开启一个appium服务

appium --no-reset -p 4724 --session-override,端口号和脚本中的端口号一致
    def __init__(self):
        desired_caps = {}
        desired_caps['app'] = appDir
        desired_caps['deviceName'] = "iPhone 7P"
        desired_caps['platformName'] = "IOS"
        desired_caps['platformVersion'] = '13.5.1'
        desired_caps['udid'] = "xxxxxxxxx"
        desired_caps['automationName'] = 'XCUITest'
        desired_caps['xcodeOrgId'] = "xxxxxx"
        desired_caps['xcodeSigningId'] = "iPhone Developer"
        desired_caps['noReset'] = False
        desired_caps['locationServicesEnabled'] = True
        desired_caps['locationServicesAuthorized'] = True
        desired_caps['showiOSLog'] = True

        self.driver = webdriver.Remote(command_executor="http://127.0.0.1:4724/wd/hub", desired_capabilities=desired_caps)

其中:
appDir app的路径
udid 手机的udid
xcodeOrgId 开发者id
noReset false为每次运行脚本都会重置App,即卸载后重置

二、运行App

1.一般第一次打开会申请一些权限

if self.elementExist(By.NAME, "允许"):
    self.driver.find_element_by_name("允许").click()
if self.elementExist(By.NAME, "使用App时允许"):
    self.driver.find_element_by_name("使用App时允许").click()
if self.elementExist(By.NAME, "允许"):
    self.driver.find_element_by_name("允许").click()
    ```

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值