IOS UI主动化测试-XCUITest 使用

打印 上一主题 下一主题

主题 1655|帖子 1655|积分 4965

一、根据平台,安装工具(内里有安装方法)
tidevice: https://github.com/alibaba/tidevice
tidevice3:https://github.com/doronz88/pymobiledevice3
pymobiledevice3:https://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(保举)



  • 步骤

    • 登录 Apple Developer Account
    • 进入 Certificates, Identifiers & Profiles > Identifiers
    • 删除近期创建的、未使用的 App ID(尤其是暂时测试用的 ID)。

  • 注意:删除后,关联的 Provisioning Profiles 会失效,需重新天生
可以正常执行,会在手机上安装:XCTTEESTUITests-Runner
首次需要 设置->通用->VPN与设备管理 将账号添加为信托,就可以正常执行case了:










免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

飞不高

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表