Die Idee ist einfach. Ich habe benutzerdefinierte UIButton
:UIButton kann nicht unter UITests angetippt werden
@IBDesignable class RadioButton: AttributedButton {
private let attributedView = AttributedView(frame: CGRect(x: 0, y: 0, width: 16, height: 16))
@IBInspectable var isActive: Bool = false {
didSet {
attributedView.removeFromSuperview()
attributedView.center = CGPoint(x: frame.size.width/2, y: frame.size.height/2)
attributedView.layer.borderWidth = 1
attributedView.cornerRadius = 8
attributedView.backgroundColor = isActive ? UIColor.scooter : UIColor.white
attributedView.layer.borderColor = isActive ? UIColor.scooter.cgColor : UIColor.silver.cgColor
addSubview(attributedView)
}
}
}
Dies ist, wie es aussieht, wenn isActive = false
:
und isActive = true
:
Alles funktioniert wie erwartet, wenn App läuft. Aber das gleiche muss ich unter UITests tun. Alles, was ich tue, ist Tippen auf diesen Knopf ... aber es wird nicht angezapft. Warum?
Wie führe ich einen Wasserhahn?
let termsRadioButton = app.buttons["termsRadioButton"]
termsRadioButton.tap()
Sobald ich tippe ich überprüfen, ob isActive = true
, wenn nicht, dann eine Warnung für I ... alert nicht unter uitests sein sollte, weil ich wirklich, dass Taste tippen. Was ist hier falsch?