gpt4 book ai didi

ios - 如何在使用 Xcode 11 和 iOS 13 进行 UI 测试期间关闭 UIActivityViewController

转载 作者:行者123 更新时间:2023-12-03 19:08:55 25 4
gpt4 key购买 nike

Apple 重新设计了出现的共享表,它现在已经破坏了我的 UI 测试。

我尝试通过 Xcode 记录新的 UI 测试,但是一旦我点击关闭按钮,测试就会终止,因此我无法捕获该事件。

最终,我只想知道如何访问下面箭头所示的灰色“X”:

最佳答案

我刚刚使用 Xcode 13 对此进行了测试,发现原来的答案不再有效。不过,我会为后代或使用以前版本的 Xcode 的人保留它。

Xcode 13

我已经使用 Xcode 13.0 对此进行了测试,并验证了它适用于 iPhone 和 iPad:

let activityListView = app.otherElements.element(matching: .other,
identifier: "ActivityListView")
XCTAssertTrue(activityListView.waitForExistence(timeout: 2.0))
activityListView.buttons["Close"].tap()

以前的版本

经过一番尝试和错误后,我能够通过以下内容找到我的特定元素所在的位置:

app.otherElements.element(boundBy: 1).buttons.element(boundBy: 0).tap()

使用 app.otherElements.element(boundBy: 1) 将为我识别共享表。我曾尝试通过辅助功能标识符找到它,但找不到有效的标识符,包括之前在 iOS 12 及更低版本中使用的有效标识符。

Please note that based on the layout of your screen, the index valuemay differ from what I am seeing.

接下来,.buttons.element(boundBy: 0).tap() 用于定位关闭按钮。我再次尝试使用标识符,但找不到任何代表该按钮的内容。

当我在测试时尝试通过控制台辨别附加信息时,我总是会导致测试崩溃。这个结果令人惊讶,因为我能够使用 Xcode 10 查询这些元素。

最终,我希望找到工作标识符值,这样我就可以拥有跨产品可靠工作的东西,而无需反复试验来找到共享表的索引值。

对于 iPad

以下内容将关闭 iPad 的弹出窗口:

app.otherElements["PopoverDismissRegion"].tap()

关于ios - 如何在使用 Xcode 11 和 iOS 13 进行 UI 测试期间关闭 UIActivityViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58381626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com