- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试关闭我的 XCUITest 套件上的警报,我目前正在使用
app.alerts.buttons["OK"].tap()
使用它可以解除警报,但应用程序会继续尝试点击按钮,然后失败并显示错误消息“UI 测试失败 - 找不到警报的匹配项”
这是控制台输出
t = 0.00s Start Test at 2016-11-03 14:07:30.827
t = 0.00s Set Up
t = 0.00s Launch uk.co.myapp
t = 4.89s Waiting for accessibility to load
t = 12.55s Wait for app to idle
t = 18.46s Snapshot accessibility hierarchy for uk.co.myapp
t = 19.24s Find: Descendants matching type Button
t = 19.25s Find: Elements matching predicate '"Enable notifications" IN identifiers'
t = 19.26s Tap "Enable notifications" Button
t = 19.26s Wait for app to idle
t = 19.40s Find the "Enable notifications" Button
t = 19.40s Snapshot accessibility hierarchy for uk.co.myapp
t = 27.43s Find: Descendants matching type Button
t = 27.48s Find: Elements matching predicate '"Enable notifications" IN identifiers'
t = 27.52s Wait for app to idle
t = 27.93s Synthesize event
t = 28.31s Wait for app to idle
t = 33.94s Tap "OK" Button
t = 33.94s Wait for app to idle
t = 35.19s Find the "OK" Button
t = 35.20s Snapshot accessibility hierarchy for uk.co.myapp
t = 39.68s Find: Descendants matching type Alert
t = 39.69s Wait for app to idle
t = 39.82s App event loop idle notification not received, will attempt to continue.
t = 39.82s App animations complete notification not received, will attempt to continue.
t = 39.83s Check for UI interruption: Descendants matching type Alert
t = 39.83s Snapshot accessibility hierarchy for com.apple.springboard
t = 39.93s Find: Descendants matching type Alert
t = 39.94s Find the "“VoucherCodes” Would Like to Send You Notifications" Alert
t = 39.94s Use cached accessibility hierarchy for com.apple.springboard
t = 39.97s Find: Descendants matching type Alert
t = 39.97s Find: Identity Binding
t = 39.98s Use cached accessibility hierarchy for com.apple.springboard
t = 39.99s Find: Descendants matching type Alert
t = 40.00s Find: Identity Binding
t = 40.01s Find: Descendants matching type Button
t = 40.01s Find: Elements matching predicate 'userTestingAttributes CONTAINS "cancel-button"'
t = 40.01s Get number of matches for: Descendants matching type Button
t = 40.13s Snapshot accessibility hierarchy for com.apple.springboard
t = 40.23s Find: Descendants matching type Alert
t = 40.23s Find: Identity Binding
t = 40.24s Find: Descendants matching type Button
t = 40.24s Get all elements bound by accessibility element for: Elements matching predicate 'userTestingAttributes CONTAINS "default-button"'
t = 40.34s Snapshot accessibility hierarchy for com.apple.springboard
t = 40.43s Find: Descendants matching type Alert
t = 40.45s Find: Identity Binding
t = 40.46s Find: Descendants matching type Button
t = 40.46s Find: Elements matching predicate 'userTestingAttributes CONTAINS "default-button"'
t = 40.47s Use cached accessibility hierarchy for com.apple.springboard
t = 40.49s Find: Descendants matching type Alert
t = 40.49s Find: Identity Binding
t = 40.50s Find: Descendants matching type Button
t = 40.50s Find: Elements matching predicate 'userTestingAttributes CONTAINS "default-button"'
t = 40.50s Find: Identity Binding
t = 40.50s Tap "OK" Button
t = 40.50s Wait for app to idle
t = 40.61s App event loop idle notification not received, will attempt to continue.
t = 40.61s App animations complete notification not received, will attempt to continue.
t = 40.62s Find the "OK" Button
t = 40.62s Snapshot accessibility hierarchy for com.apple.springboard
t = 40.70s Find: Descendants matching type Alert
t = 40.71s Find: Identity Binding
t = 40.71s Find: Descendants matching type Button
t = 40.71s Find: Elements matching predicate 'userTestingAttributes CONTAINS "default-button"'
t = 40.72s Find: Identity Binding
t = 40.72s Wait for app to idle
t = 40.84s App event loop idle notification not received, will attempt to continue.
t = 40.84s App animations complete notification not received, will attempt to continue.
t = 40.84s Synthesize event
t = 41.17s Wait for app to idle
t = 41.43s App event loop idle notification not received, will attempt to continue.
t = 41.43s App animations complete notification not received, will attempt to continue.
t = 41.44s Snapshot accessibility hierarchy for com.apple.springboard
t = 41.52s Find: Descendants matching type Alert
t = 41.53s Find: Identity Binding
t = 41.54s Wait for view controller view-did-disappear
t = 42.21s Snapshot accessibility hierarchy for uk.co.myapp
t = 45.68s Find: Descendants matching type Alert
t = 45.69s Wait for app to idle
t = 46.82s Find the "OK" Button (retry 1)
t = 46.82s Snapshot accessibility hierarchy for
我的应用程序 t = 50.18s 查找:匹配类型警报的后代 t = 50.19s 等待应用空闲 t = 51.38s 找到“确定”按钮(重试 2) t = 51.38s uk.myapp 的快照可访问性层次结构 t = 55.06s 查找:匹配类型警报的后代 t = 55.06s 等待应用空闲 t = 55.44s 断言失败:signUpSetUp.swift:21: UI 测试失败 - 未找到警报的匹配项查询输入为 {( 应用程序 0x7fb51cf80840:{{0.0, 0.0}, {375.0, 667.0}}, 标签
有没有更好的方法来解决这个问题?或者有没有解决我出错的地方?对此困惑了一段时间!
最佳答案
我改进了@user3271402 的答案
addUIInterruptionMonitorWithDescription("alert description") { (alert) -> Bool in
let alertButton = alert.buttons["OK"]
if alertButton.exists {
alertButton.tap()
return true
}
return false
}
app.tap()
如果警报存在,只需点击。如果警报没有发生,则返回 false,然后点击应用程序并结束。
关于swift - 关闭警报 XCUITest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40403805/
我想为原生 iOS 应用程序创建几个测试。更准确地说,我想测试深层链接。但我不确定如何触发与 XCUITest 的深层链接,我真的不知道如何 launch()和 launcArguments ( ht
这是我第一次尝试在 AppCenter 中测试我的 Cordova iOS 应用程序。我已经阅读了文档,它似乎在 iOS 混合应用程序上进行 UI 测试,我应该使用 XCUITest 框架,所以这就是
我在 CI/CD 提供程序(如 CircleCI)上运行 UI 测试,我需要读取多个 secret 环境变量(如测试用户名和密码)。我可以很容易地设置它,但我不明白如何将它们正确地传递给测试用例。 我
我正在尝试通过命令行将值传递给我的 XCUITest。我知道可以通过以下方式为 XCTest(非 UI)执行此操作: xcodebuild -verbose test -workspace MyWor
我的应用程序因以下堆栈而崩溃 - Thread 1Queue : com.apple.main-thread (serial) #0 0x0722dd39 in ___forwarding___ ()
我在作为 ChildViewController 呈现的 ViewController 上有一个关闭按钮。我已打开此按钮的辅助功能,辅助功能标识符为 closeButton .这个按钮没有任何文本,它
我正在考虑使用 XCUITest 为我的 iOS 应用程序进行 UI 测试。看起来 XCUITest 具有广泛的功能,包括使用多个应用程序的能力。但是,多应用程序支持似乎有些受限。 似乎使用 XCUI
我是 XCUITest 的新手,遇到了它无法识别警报的问题。 我使用录音机来获取命令,但是当我尝试播放它时,它失败并显示错误: 未找到“查找:后代”匹配类型来自输入的警报的匹配项... let app
测试失败后、断言后或者即使元素未找到或不可命中,我可以在 XCUITest 中执行操作 如果失败或输入断言,应用程序将保持这种状态几个小时。像这样assert or fail 如果失败我可以让测试调用
我试图让 XCUITest 使用下面的代码与远程通知交互,但我很好奇此代码是否只会单击我的应用程序通知或收到的任何通知(取决于哪个先到达)? let springboard = XCUIApplica
让模拟器吐出位置的唯一方法是更改模拟器本身的位置。当我更改方案中的设置时,它似乎没有做任何事情。 我错过了什么吗? Xcode 版本 10.2 (10E125) 最佳答案 这应该是答案: http
某些元素在 XCUITest 中不“可见”,无法为它们断言,它们从未被发现。即使我通过调试打印 XCUIApplication() ,元素也不会显示。 最佳答案 我发现如果你设置了 isAccessb
正在尝试找到一种解决方案来自动执行 XCUITest 应用程序的任务终止... static let springboard:XCUIApplication? = XCUIApplication(bu
我正在尝试点击链接标签中的链接。使用录音机,我有点击事件的代码 let link = XCUIApplication().scrollViews.otherElements.links["link h
我需要自动化这个场景: 在第一台设备上执行某项操作(点击 UI 元素) 在第二台设备上验证某项(验证 UI 元素) 在第二台设备上执行某操作 在第一台设备上验证某项 这在 XCUITest 上可行吗?
我有一个带有 tableView 和细节 vc 的简单项目。 tableView 显示带有“cell (n)”文本的 20 行,详细 View 显示带有按下单元格的标签。我想断言,只要点击一个单元格,
我有一个包含一些项目的 Collection View 。在我的 UI 测试期间,我点击一个按钮,这将触发一个网络请求,该请求完成后,将在索引 0 处向该 Collection View 中插入一个单
是否可以在 XCUITest 中验证通知横幅已发送到屏幕? 我可以向通知添加可访问性标识符,但是当横幅出现在屏幕上时,我无法让 XCUITest 与之交互。我知道 XCUITest 在与应用程序不同的
是否有任何已知方法可以影响 XCUITest 调用测试方法的顺序?目前,以何种顺序调用哪种测试方法似乎完全是任意的。 这使得无法定义特定顺序。一般来说,Xcode 管理 XCUITest 运行的方式不
我有一个带有 Today Widget 的应用程序。所以我想对其进行一些 UI 测试。 我找到了打开今日/通知面板的方法。这看起来很简单: let statusBar = XCUIApplicatio
我是一名优秀的程序员,十分优秀!