Skip to content

Commit

Permalink
fix: Fixed Xpath lookup for Xcode 14.3 (#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan-Maor authored Apr 4, 2023
1 parent 209d01a commit 3e0b191
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions WebDriverAgentLib/Categories/XCUIElement+FBUID.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import "XCUIElement+FBUID.h"

#import "FBElementUtils.h"
#import "FBLogger.h"
#import "XCUIApplication.h"
#import "XCUIElement+FBUtilities.h"

Expand All @@ -35,6 +36,10 @@ - (NSString *)fb_uid

@implementation FBXCElementSnapshotWrapper (FBUID)

static void swizzled_validatePredicateWithExpressionsAllowed(id self, SEL _cmd, id predicate, BOOL withExpressionsAllowed)
{
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-load-method"
+ (void)load
Expand All @@ -43,6 +48,19 @@ + (void)load
NSAssert(XCElementSnapshotCls != nil, @"Could not locate XCElementSnapshot class");
Method uidMethod = class_getInstanceMethod(self.class, @selector(fb_uid));
class_addMethod(XCElementSnapshotCls, @selector(fb_uid), method_getImplementation(uidMethod), method_getTypeEncoding(uidMethod));

// Support for Xcode 14.3 requires disabling the new predicate validator, see https://github.com/appium/appium/issues/18444
Class XCTElementQueryTransformerPredicateValidatorCls = objc_lookUpClass("XCTElementQueryTransformerPredicateValidator");
if (XCTElementQueryTransformerPredicateValidatorCls == nil) {
return;
}
Method validatePredicateMethod = class_getClassMethod(XCTElementQueryTransformerPredicateValidatorCls, NSSelectorFromString(@"validatePredicate:withExpressionsAllowed:"));
if (validatePredicateMethod == nil) {
[FBLogger log:@"Could not find method +[XCTElementQueryTransformerPredicateValidator validatePredicate:withExpressionsAllowed:]"];
return;
}
IMP swizzledImp = (IMP)swizzled_validatePredicateWithExpressionsAllowed;
method_setImplementation(validatePredicateMethod, swizzledImp);
}
#pragma diagnostic pop

Expand Down

0 comments on commit 3e0b191

Please sign in to comment.