So I was reading an article: https://shashikantjagtap.net/organising-xcuielements-with-swift-enumerations/
It suggests an way to organize XCUItest as follows:
enum HomeScreen: String {
case guestButton = "Hello"
case registerButton = "Register"
case loginButton = "Login"
case welcomeText = "Welcome"
case introText = "Introduction to app"
var element: XCUIElement {
if buttonElements.contains(self) {
return XCUIApplication().buttons[self.rawValue]
}
if textElements.contains(self) {
return XCUIApplication().staticTexts[self.rawValue]
}
fatalError("Element not found")
}
private var buttonElements: [HomeScreen] {
return [.guestButton, .registerButton, .loginButton]
}
private var textElements: [HomeScreen] {
return [.welcomeText, .introText]
}
}
But say I an element that act as a checkmark and is a child of a specific component. Can you add that image to this enum?
The things I wanna check is:
app.buttons["button_with_checkmark_1"].images["dynamic_image_checkmark"].exists
app.buttons["button_with_checkmark_2"].images["dynamic_image_checkmark"].exists
app.buttons["button_with_checkmark_3"].images["dynamic_image_checkmark"].exists
But how can you get access to the image with the structure suggested above?
Aucun commentaire:
Enregistrer un commentaire