0
這個想法很簡單。我有自定義UIButton
:UIButton不能在UITests下使用
@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)
}
}
}
這是它的外觀時isActive = false
:
和isActive = true
:
一切工作的應用程序運行時如預期。但是我需要在UITests下做同樣的事情。我所做的只是點擊那個按鈕......但它並未點擊。爲什麼?
如何執行水龍頭?
let termsRadioButton = app.buttons["termsRadioButton"]
termsRadioButton.tap()
一旦我點擊我檢查,如果isActive = true
,如果沒有,那麼我顯示一個警告...警告不應該下uitests因爲我真的輕按該按鈕。這裏有什麼問題?