标题: IOS UI主动化测试-XCUITest 使用 [打印本页] 作者: 飞不高 时间: 2025-4-29 04:26 标题: IOS UI主动化测试-XCUITest 使用 一、根据平台,安装工具(内里有安装方法)
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(保举)