IOS UI自动化测试-XCUITest 使用

一、根据平台,安装工具(里面有安装方法)

tidevice: https://github.com/alibaba/tidevice

tidevice3https://github.com/doronz88/pymobiledevice3

pymobiledevice3https://github.com/doronz88/pymobiledevice3

xcode,MAC的App store 安装

二、查看应用的 Bundle Identifier(包标识符)

t3 app list

或者 pymobiledevice3 apps list |grep xxx

三、创建项目

Xcode->File->New→Project...

起一个名字

选择位置 后点击 Create

创建后如下:

四、授权:

左侧不显示文件后缀:

执行 代码:

func testExample() throws {

//        // UI tests must launch the application that they test.

//        let app = XCUIApplication()

//        app.launch()

        print("testConfirmDel start...")

        let shouwei = XCUIApplication(bundleIdentifier: "net.qihoo.360mobilesafe")

        shouwei.launch()

        if (shouwei.staticTexts["卫士"].exists){

            shouwei.staticTexts["卫士"].tap()

         }

        let element = shouwei.staticTexts.containing(.staticText, identifier: "手机瘦身").element

        if element.waitForExistence(timeout: 8) {

            element.tap()

        }

        while(true){

            if (shouwei.staticTexts["卫士"].exists){

                shouwei.staticTexts["卫士"].tap()

             }

            sleep(2)

            if (shouwei.staticTexts["守护中心"].exists){

                shouwei.staticTexts["守护中心"].tap()

            }

        }

        print("testConfirmDel End")

        // Use XCTAssert and related functions to verify your tests produce the correct results.

    }

    @MainActor

    func testMyTest() throws {

        print("testtestMyTest start...")

        

    }

连接iphone设备后执行:

如果提示这个错误: /Users/qihoo/TestDev/XCTTEEST/XCTTEEST.xcodeproj Communication with Apple failed. Your maximum App ID limit has been reached. You may create up to 10 App IDs every 7 days.

这个错误表明你 已达到 Apple 开发者账户的 App ID 创建限制(7 天内最多 10 个)。以下是详细的解决方案:


 检查并删除未使用的 App ID(推荐)

  • 步骤

    1. 登录 Apple Developer Account

    2. 进入 Certificates, Identifiers & Profiles > Identifiers

    3. 删除近期创建的、未使用的 App ID(尤其是临时测试用的 ID)。

  • 注意:删除后,关联的 Provisioning Profiles 会失效,需重新生成

可以正常执行,会在手机上安装:XCTTEESTUITests-Runner

首次需要 设置->通用->VPN与设备管理 将账号添加为信任,就可以正常执行case了:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

3个L

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值