8

首先是的,我已经看到了这个问题,但目前没有答案。

根本问题是我目前XCUITesting是本地化的应用程序,因此UIAlertActions 已本地化,因此我找不到按钮。

我可以做一个 hack,其中我将Localizable.strings在我的 UITesting 包中包含所有内容,然后在尝试获取这样的按钮时获取本地化版本。

let localizedAlertTitle = ...(some function to fetch localized name)
let localizedButtonName = ...(some function to fetch localized name)
self.app
    .alerts[localizedAlertTitle]
    .buttons[localizedButtonName]
    .tap()

另一种方法可能是做这个答案所说的黑客,但它太hacky并且有样板。

有没有办法accessibilityIdentifier在 UIAlertAction 上设置?

4

0 回答 0