Swift UITest - 将使用两者之一。哪个是未定义的

Swift UITest - One of the two will be used. Which one is undefined

我正在尝试进行一些 UITest,但遇到了烦人的问题。

当我尝试获取 tableView/tableCell 时,我在日志中收到此文本,但我的测试失败了。

objc[18223]: Class VCWeakObjectHolder is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework/Frameworks/ViceroyTrace.framework/ViceroyTrace (0x131ad04d0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework/AVConference (0x131797e38). One of the two will be used. Which one is undefined.

这是我用来进行测试的代码:

let app = XCUIApplication()
let table = app.tables

let cell = table.cells.element(matching: .cell, identifier: "cell_settings_1")
_ = cell.waitForExistence(timeout: 10.0)
cell.tap()

XCTAssert(app.otherElements["view_about"].exists)

我的 tableViewCell 有这个字符串作为标识符,这不是问题。

当我尝试记录测试时,收到此错误:

有人可以帮助我吗?

当在可访问性层中找不到该元素时,通常会出现此错误。重要的是,这与 UI 测试无关。

暂时忽略测试,并从 XCode 中的开发人员工具中打开辅助功能检查器。如果您使用小目标图标,并将鼠标悬停在您想要与之交互的对象上,那么很有可能无法将其作为可访问性元素找到。如果是这种情况,您将需要修复应用程序中元素的可访问性。有时这很容易,有时则不然。视具体情况而定。

可能还有其他原因导致您看到此错误,但我遇到的所有情况都是由上述问题引起的。

经过这么多次我发现了我的错误。

问题是我在视图的父级中放置了一个可访问性标识符。然后,里面的元素将永远无法正常工作。

这是一张图片:

因此,在图像情况下,"view_about" 内部的任何内容都不会被测试(甚至是记录器)检测到。