Emjey
Emjey

Reputation: 2063

Element Property shows Enabled always even if the element is disabled

I find in the Appium inspector and even isenabled? code, that the element that has userinteraction = false shows enabled = true in Appium.

This happens when I view element in iOS on both device and simulator.

I need to pass a check, that returns me enabled = false if the element is disabled.

I need to know if its an issue with Appium or which property in iOS element, should be modified so that Appium recognises that element status to be True/False based on the element being enabled/disabled respectively.

Upvotes: 4

Views: 935

Answers (1)

ikroop
ikroop

Reputation: 106

When setting the userInteraction property, also add/remove .notEnabled accessibility trait for that view

func disable() {
    view.isUserInteractionEnabled = false
    view.accessibilityTraits.insert(.notEnabled)
}

func enable() {
    view.isUserInteractionEnabled = true
    view.accessibilityTraits.remove(.notEnabled)
}

Upvotes: 0

Related Questions