一、根据平台,安装工具(里面有安装方法)
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(推荐)
-
步骤:
-
进入 Certificates, Identifiers & Profiles > Identifiers
-
删除近期创建的、未使用的 App ID(尤其是临时测试用的 ID)。
-
注意:删除后,关联的 Provisioning Profiles 会失效,需重新生成
可以正常执行,会在手机上安装:XCTTEESTUITests-Runner
首次需要 设置->通用->VPN与设备管理 将账号添加为信任,就可以正常执行case了: