当试图点击警报按钮时,一个很小的UI测试失败了,我缺少什么步骤?
我正在尝试使用以下代码(从recording my steps获取)点击下面显示的警报中的“继续”按钮。
[:find ?artist-name ?release-name
:keys artist release
:where [?release :release/name ?release-name]
[?release :release/artists ?artist]
[?artist :artist/name ?artist-name]]
运行测试时,它在最后一行(即let app = XCUIApplication()
let salesforceloginbuttonButton = app.buttons["salesforceLoginButton"]
salesforceloginbuttonButton.tap()
let posWantsToUseSalesforceComToSignInAlert = app.alerts["“POS” Wants to Use “salesforce.com” to Sign In"]
let continueButton = posWantsToUseSalesforceComToSignInAlert.buttons["Continue"]
continueButton.tap()
)失败,并显示错误continueButton.tap()
。
注意:
No matches found for Find: Descendants matching type Alert from input
后,应用将启动并显示警报答案 0 :(得分:0)
我认为您的警报无法识别,可能是因为双引号
您可以尝试像这样显式设置警报的标识符:
let alert = UIAlertController(title: "Alert", message: "msg", preferredStyle: .alert)
alert.view.accessibilityIdentifier = "myAlert"
然后在您的测试中:
let alert = app.alerts["myAlert"]
let button = alert.buttons["Continue"]
button.tap()