Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed Xpath lookup for Xcode 14.3 #681

Merged
merged 4 commits into from
Apr 4, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 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,18 @@ + (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) {
Method validatePredicateMethod = class_getClassMethod(XCTElementQueryTransformerPredicateValidatorCls, NSSelectorFromString(@"validatePredicate:withExpressionsAllowed:"));
if (validatePredicateMethod != nil) {
IMP swizzledImp = (IMP)swizzled_validatePredicateWithExpressionsAllowed;
method_setImplementation(validatePredicateMethod, swizzledImp);
} else {
[FBLogger log:@"Could not find method +[XCTElementQueryTransformerPredicateValidator validatePredicate:withExpressionsAllowed:]"];
}
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
}
}
#pragma diagnostic pop

Expand Down