0
我正在为macOS开发基于文档的应用程序。如何在测试案例开始时关闭现有的NSWindow?如何使用Xcode在UI测试期间关闭NSWindow?
我正在为macOS开发基于文档的应用程序。如何在测试案例开始时关闭现有的NSWindow?如何使用Xcode在UI测试期间关闭NSWindow?
这是诀窍的代码。我有问题没有保存。不知道为什么,但后来我意识到可能有些情况下我仍然想要保存现有的文档。
var untitledWindow = app.windows["Untitled"]
if untitledWindow.exists {
untitledWindow.typeKey("w", modifierFlags:.command)
//untitledWindow.buttons[XCUIIdentifierCloseWindow].click() should work too
if untitledWindow.buttons["Save"].exists{
untitledWindow.buttons["Save"].click()
}
if untitledWindow.buttons["Replace"].exists {
untitledWindow.buttons["Replace"].click()
}
}