Last active
August 29, 2015 14:04
-
-
Save wearhere/3dc3f0306489adafe3b2 to your computer and use it in GitHub Desktop.
Workaround for `UIAElement.isEnabled` sometimes returning false positives.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m | |
index 375cba2..2cac09a 100644 | |
--- a/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m | |
+++ b/Sources/Classes/UIAutomation/User Interface Elements/SLElement.m | |
@@ -362,6 +362,22 @@ UIAccessibilityTraits SLUIAccessibilityTraitAny = 0; | |
return isVisible; | |
} | |
+- (BOOL)isEnabled { | |
+ __block BOOL isEnabled = [super isEnabled]; | |
+ | |
+ // sometimes UIAutomation says that a button is enabled when it's not, so we double check if possible | |
+ // (with no timeout--`isEnabled` should evaluate the current state of the element) | |
+ if (isEnabled) { | |
+ [self examineMatchingObject:^(NSObject *object) { | |
+ if ([object respondsToSelector:@selector(isEnabled)]) { | |
+ isEnabled = [(id)object isEnabled]; | |
+ } | |
+ } timeout:0.0]; | |
+ } | |
+ | |
+ return isEnabled; | |
+} | |
+ | |
#pragma mark - | |
- (void)tapAtActivationPoint { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment