Skip to content

Commit

Permalink
Add basic support of Xcode10.2 (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Feb 26, 2019
1 parent 8280a31 commit 1fb1117
Show file tree
Hide file tree
Showing 22 changed files with 341 additions and 69 deletions.
107 changes: 85 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: objective-c
osx_image: xcode9.2
sudo: false

cache:
Expand All @@ -13,25 +12,89 @@ branches:
only:
- master

env:
# Builds
- ACTION=build TARGET=runner SDK=sim
- ACTION=build TARGET=runner SDK=device
matrix:
include:
# Builds
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=build TARGET=runner SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=build TARGET=runner SDK=device
# Analyze
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=analyze TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=analyze TARGET=runner SDK=sim
# Unit tests
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=unit_test DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=unit_test DEST=ipad TARGET=lib SDK=sim
# Integration tests iPhone
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_1 DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_2 DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_3 DEST=iphone TARGET=lib SDK=sim
# Integration tests iPad
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_1 DEST=ipad TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_2 DEST=ipad TARGET=lib SDK=sim
- os: osx
osx_image: xcode9.2
env: IPHONE_MODEL="iPhone SE" IPAD_MODEL="iPad Air 2" IOS_VERSION="11.2" ACTION=int_test_3 DEST=ipad TARGET=lib SDK=sim

# Analyze
- ACTION=analyze TARGET=lib SDK=sim
- ACTION=analyze TARGET=runner SDK=sim

# Unit tests
- ACTION=unit_test DEST=iphone TARGET=lib SDK=sim
- ACTION=unit_test DEST=ipad TARGET=lib SDK=sim

# Integration tests iPhone
- ACTION=int_test_1 DEST=iphone TARGET=lib SDK=sim
- ACTION=int_test_2 DEST=iphone TARGET=lib SDK=sim
- ACTION=int_test_3 DEST=iphone TARGET=lib SDK=sim

# Integration tests iPad
- ACTION=int_test_1 DEST=ipad TARGET=lib SDK=sim
- ACTION=int_test_2 DEST=ipad TARGET=lib SDK=sim
- ACTION=int_test_3 DEST=ipad TARGET=lib SDK=sim
# Builds
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=build TARGET=runner SDK=sim
# Fails to build because of a missing signature
# - os: osx
# osx_image: xcode10.2
# env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=build TARGET=runner SDK=device
# Analyze
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=analyze TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=analyze TARGET=runner SDK=sim
# Unit tests
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=unit_test DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=unit_test DEST=ipad TARGET=lib SDK=sim
# Integration tests iPhone
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_1 DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_2 DEST=iphone TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_3 DEST=iphone TARGET=lib SDK=sim
# Integration tests iPad
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_1 DEST=ipad TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_2 DEST=ipad TARGET=lib SDK=sim
- os: osx
osx_image: xcode10.2
env: IPHONE_MODEL="iPhone X" IPAD_MODEL="iPad Air 2" IOS_VERSION="12.2" ACTION=int_test_3 DEST=ipad TARGET=lib SDK=sim
8 changes: 8 additions & 0 deletions PrivateHeaders/XCTest/XCAXClient_iOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@
}
@property double AXTimeout;

// Removed since Xcode10.2
+ (id)sharedClient;

// Added since Xcode 10.2
@property(readonly) id applicationProcessTracker;

- (BOOL)_setAXTimeout:(double)arg1 error:(id *)arg2;
- (NSData *)screenshotData;
- (BOOL)performAction:(int)arg1 onElement:(id)arg2 value:(id)arg3 error:(id *)arg4;
- (id)parameterizedAttributeForElement:(id)arg1 attribute:(id)arg2 parameter:(id)arg3;
- (BOOL)setAttribute:(id)arg1 value:(id)arg2 element:(id)arg3 outError:(id *)arg4;
// Removed in Xcode 10.2
- (id)attributesForElement:(id)arg1 attributes:(id)arg2;
// since Xcode10
- (id)attributesForElement:(id)arg1 attributes:(id)arg2 error:(id *)arg3;
- (id)attributesForElementSnapshot:(id)arg1 attributeList:(id)arg2;
- (id)snapshotForApplication:(id)arg1 attributeList:(id)arg2 parameters:(id)arg3;
- (id)defaultParameters;
Expand Down
2 changes: 2 additions & 0 deletions PrivateHeaders/XCTest/XCElementSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@
+ (id)snapshotAttributesForElementSnapshotKeyPaths:(id)arg1;
// Available since Xcode 10.0-beta4 on
+ (id)axAttributesForElementSnapshotKeyPaths:(id)arg1;
// Since Xcode 10.2
+ (id)axAttributesForElementSnapshotKeyPaths:(id)arg1 isMacOS:(_Bool)arg2;

@end
4 changes: 4 additions & 0 deletions PrivateHeaders/XCTest/XCUIDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

@interface XCUIDevice ()

// Since Xcode 10.2
@property (readonly) id accessibilityInterface; // implements XCUIAccessibilityInterface
@property (readonly) id eventSynthesizer; // implements XCUIEventSynthesizing

- (void)pressLockButton;
- (void)holdHomeButtonForDuration:(double)arg1;
- (void)_silentPressButton:(long long)arg1;
Expand Down
4 changes: 2 additions & 2 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function define_xc_macros() {
esac

case "${DEST:-}" in
"iphone" ) XC_DESTINATION="-destination \"name=iPhone SE,OS=11.2\"";;
"ipad" ) XC_DESTINATION="-destination \"name=iPad Air 2,OS=11.2\"";;
"iphone" ) XC_DESTINATION="-destination \"name=${IPHONE_MODEL},OS=${IOS_VERSION}\"";;
"ipad" ) XC_DESTINATION="-destination \"name=${IPAD_MODEL},OS=${IOS_VERSION}\"";;
esac

case "$ACTION" in
Expand Down
10 changes: 10 additions & 0 deletions WebDriverAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
71555A3E1DEC460A007D4A8B /* NSExpression+FBFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 71555A3C1DEC460A007D4A8B /* NSExpression+FBFormat.m */; };
7155D703211DCEF400166C20 /* FBMjpegServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7155D701211DCEF400166C20 /* FBMjpegServer.h */; };
7155D704211DCEF400166C20 /* FBMjpegServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7155D702211DCEF400166C20 /* FBMjpegServer.m */; };
7157B291221DADD2001C348C /* FBXCAXClientProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7157B28F221DADD2001C348C /* FBXCAXClientProxy.h */; };
7157B292221DADD2001C348C /* FBXCAXClientProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 7157B290221DADD2001C348C /* FBXCAXClientProxy.m */; };
715AFAC11FFA29180053896D /* FBScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AFABF1FFA29180053896D /* FBScreen.h */; };
715AFAC21FFA29180053896D /* FBScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC01FFA29180053896D /* FBScreen.m */; };
715AFAC41FFA2AAF0053896D /* FBScreenTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 715AFAC31FFA2AAF0053896D /* FBScreenTests.m */; };
Expand Down Expand Up @@ -501,6 +503,8 @@
71555A3C1DEC460A007D4A8B /* NSExpression+FBFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSExpression+FBFormat.m"; sourceTree = "<group>"; };
7155D701211DCEF400166C20 /* FBMjpegServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBMjpegServer.h; sourceTree = "<group>"; };
7155D702211DCEF400166C20 /* FBMjpegServer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBMjpegServer.m; sourceTree = "<group>"; };
7157B28F221DADD2001C348C /* FBXCAXClientProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBXCAXClientProxy.h; sourceTree = "<group>"; };
7157B290221DADD2001C348C /* FBXCAXClientProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBXCAXClientProxy.m; sourceTree = "<group>"; };
715AFABF1FFA29180053896D /* FBScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBScreen.h; sourceTree = "<group>"; };
715AFAC01FFA29180053896D /* FBScreen.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBScreen.m; sourceTree = "<group>"; };
715AFAC31FFA2AAF0053896D /* FBScreenTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBScreenTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1155,6 +1159,8 @@
7140974A1FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.m */,
EE5A24401F136C8D0078B1D9 /* FBXCodeCompatibility.h */,
EE5A24411F136C8D0078B1D9 /* FBXCodeCompatibility.m */,
7157B28F221DADD2001C348C /* FBXCAXClientProxy.h */,
7157B290221DADD2001C348C /* FBXCAXClientProxy.m */,
EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */,
EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */,
EE35AD791E3B80C000A02D78 /* FBXCTestDaemonsProxy.h */,
Expand Down Expand Up @@ -1538,6 +1544,7 @@
EE35AD0B1E3B77D600A02D78 /* _XCTDarwinNotificationExpectationImplementation.h in Headers */,
EE35AD491E3B77D600A02D78 /* XCTestExpectation.h in Headers */,
EE158AE81CBD456F00A3E3F0 /* FBElementTypeTransformer.h in Headers */,
7157B291221DADD2001C348C /* FBXCAXClientProxy.h in Headers */,
EE158AD21CBD456F00A3E3F0 /* FBElementCache.h in Headers */,
EE35AD5A1E3B77D600A02D78 /* XCTMetric.h in Headers */,
EE35AD461E3B77D600A02D78 /* XCTestContextScope.h in Headers */,
Expand Down Expand Up @@ -1975,6 +1982,7 @@
EE35AD7C1E3B80C000A02D78 /* FBXCTestDaemonsProxy.m in Sources */,
EE158AB51CBD456F00A3E3F0 /* XCUIElement+FBTap.m in Sources */,
EE18883B1DA661C400307AA8 /* FBMathUtils.m in Sources */,
7157B292221DADD2001C348C /* FBXCAXClientProxy.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2272,6 +2280,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = WebDriverAgentLib/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
Expand Down Expand Up @@ -2301,6 +2310,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = WebDriverAgentLib/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
Expand Down
4 changes: 2 additions & 2 deletions WebDriverAgentLib/Categories/XCElementSnapshot+FBHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "FBFindElementCommands.h"
#import "FBRunLoopSpinner.h"
#import "FBLogger.h"
#import "XCAXClient_iOS.h"
#import "FBXCAXClientProxy.h"
#import "XCTestDriver.h"
#import "XCTestPrivateSymbols.h"
#import "XCUIElement.h"
Expand Down Expand Up @@ -53,7 +53,7 @@ - (XCElementSnapshot *)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types

- (id)fb_attributeValue:(NSNumber *)attribute
{
NSDictionary *attributesResult = [[XCAXClient_iOS sharedClient] attributesForElementSnapshot:self attributeList:@[attribute]];
NSDictionary *attributesResult = [FBXCAXClientProxy.sharedClient attributesForElementSnapshot:self attributeList:@[attribute]];
return (id __nonnull)attributesResult[attribute];
}

Expand Down
2 changes: 1 addition & 1 deletion WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ - (NSDictionary *)fb_accessibilityTree
{
[self fb_waitUntilSnapshotIsStable];
// We ignore all elements except for the main window for accessibility tree
return [self.class accessibilityInfoForElement:self.fb_lastSnapshot];
return [self.class accessibilityInfoForElement:(self.fb_snapshotWithAttributes ?: self.fb_lastSnapshot)];
}

+ (NSDictionary *)dictionaryForElement:(XCElementSnapshot *)snapshot recursive:(BOOL)recursive
Expand Down
8 changes: 6 additions & 2 deletions WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import "XCUIElement+FBAccessibility.h"

#import "FBConfiguration.h"
#import "XCElementSnapshot+FBHelpers.h"
#import "XCTestPrivateSymbols.h"
#import "XCUIElement+FBUtilities.h"
Expand All @@ -17,7 +18,7 @@ @implementation XCUIElement (FBAccessibility)

- (BOOL)fb_isAccessibilityElement
{
return self.fb_lastSnapshot.fb_isAccessibilityElement;
return (self.fb_snapshotWithAttributes ?: self.fb_lastSnapshot).fb_isAccessibilityElement;
}

@end
Expand All @@ -26,7 +27,10 @@ @implementation XCElementSnapshot (FBAccessibility)

- (BOOL)fb_isAccessibilityElement
{
return [(NSNumber *)[self fb_attributeValue:FB_XCAXAIsElementAttribute] boolValue];
NSNumber *isAccessibilityElement = self.additionalAttributes[FB_XCAXAIsElementAttribute];
return nil != isAccessibilityElement
? isAccessibilityElement.boolValue
: [(NSNumber *)[self fb_attributeValue:FB_XCAXAIsElementAttribute] boolValue];
}

@end
8 changes: 3 additions & 5 deletions WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,9 @@ - (XCAccessibilityElement *)elementAtPoint:(CGPoint)point

- (BOOL)fb_isVisible
{
if ([FBConfiguration shouldLoadSnapshotWithAttributes]) {
NSNumber *isVisible = self.additionalAttributes[FB_XCAXAIsVisibleAttribute];
if (isVisible != nil) {
return isVisible.boolValue;
}
NSNumber *isVisible = self.additionalAttributes[FB_XCAXAIsVisibleAttribute];
if (isVisible != nil) {
return isVisible.boolValue;
}

NSNumber *cachedValue = [self fb_cachedVisibilityValue];
Expand Down
9 changes: 6 additions & 3 deletions WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#import "FBMathUtils.h"
#import "FBPredicate.h"
#import "FBRunLoopSpinner.h"
#import "FBXCAXClientProxy.h"
#import "FBXCodeCompatibility.h"
#import "FBXCTestDaemonsProxy.h"
#import "XCAXClient_iOS.h"
#import "XCTElementSetTransformer-Protocol.h"
#import "XCTestManager_ManagerInterface-Protocol.h"
#import "XCTestPrivateSymbols.h"
Expand Down Expand Up @@ -88,7 +88,7 @@ - (nullable XCElementSnapshot *)fb_snapshotWithAttributes {

static dispatch_once_t initializeAttributesAndParametersToken;
dispatch_once(&initializeAttributesAndParametersToken, ^{
defaultParameters = [[XCAXClient_iOS sharedClient] defaultParameters];
defaultParameters = [FBXCAXClientProxy.sharedClient defaultParameters];
// Names of the properties to load. There won't be lazy loading for missing properties,
// thus missing properties will lead to wrong results
NSArray<NSString *> *propertyNames = @[
Expand All @@ -108,6 +108,9 @@ - (nullable XCElementSnapshot *)fb_snapshotWithAttributes {
if (![axAttributes containsObject:FB_XCAXAIsVisibleAttribute]) {
axAttributes = [axAttributes arrayByAddingObject:FB_XCAXAIsVisibleAttribute];
}
if (![axAttributes containsObject:FB_XCAXAIsElementAttribute]) {
axAttributes = [axAttributes arrayByAddingObject:FB_XCAXAIsElementAttribute];
}
}
});

Expand Down Expand Up @@ -214,7 +217,7 @@ - (XCElementSnapshot *)fb_lastSnapshotFromQuery
- (BOOL)fb_waitUntilSnapshotIsStable
{
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[[XCAXClient_iOS sharedClient] notifyWhenNoAnimationsAreActiveForApplication:self.application reply:^{dispatch_semaphore_signal(sem);}];
[FBXCAXClientProxy.sharedClient notifyWhenNoAnimationsAreActiveForApplication:self.application reply:^{dispatch_semaphore_signal(sem);}];
dispatch_time_t timeout = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FBANIMATION_TIMEOUT * NSEC_PER_SEC));
BOOL result = 0 == dispatch_semaphore_wait(sem, timeout);
if (!result) {
Expand Down
36 changes: 26 additions & 10 deletions WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,41 @@

@implementation XCUIElement (WebDriverAttributesForwarding)

- (id)forwardingTargetForSelector:(SEL)aSelector
- (XCElementSnapshot *)fb_snapshotForAttributeName:(NSString *)name
{
struct objc_method_description descr = protocol_getMethodDescription(@protocol(FBElement), aSelector, YES, YES);
BOOL isWebDriverAttributesSelector = descr.name != nil;
if (!isWebDriverAttributesSelector) {
return nil;
}
if (!self.exists) {
return [XCElementSnapshot new];
}

if (descr.name == @selector(isWDVisible)) {

if ([name isEqualToString:FBStringify(XCUIElement, isWDVisible)]
|| [name isEqualToString:FBStringify(XCUIElement, isWDAccessible)]
|| [name isEqualToString:FBStringify(XCUIElement, isWDAccessibilityContainer)]) {
// These attrbiutes are special, because we can only retrieve them from
// the snapshot if we explicitly ask XCTest to include them into the query while taking it.
// That is why fb_snapshotWithAttributes method must be used instead of the default fb_lastSnapshot
// call
return (self.fb_snapshotWithAttributes ?: self.fb_lastSnapshot) ?: [XCElementSnapshot new];
}
// If lastSnapshot is still missing aplication is probably not active. Returning empty element instead of crashing.
// This will work well, if element search is requested (will not match anything) and reqesting properties values (will return nils).

return self.fb_lastSnapshot ?: [XCElementSnapshot new];
}

- (id)fb_valueForWDAttributeName:(NSString *)name
{
NSString *wdAttributeName = [FBElementUtils wdAttributeNameForAttributeName:name];
XCElementSnapshot *snapshot = [self fb_snapshotForAttributeName:wdAttributeName];
return [snapshot fb_valueForWDAttributeName:name];
}

- (id)forwardingTargetForSelector:(SEL)aSelector
{
struct objc_method_description descr = protocol_getMethodDescription(@protocol(FBElement), aSelector, YES, YES);
SEL webDriverAttributesSelector = descr.name;
return nil == webDriverAttributesSelector
? nil
: [self fb_snapshotForAttributeName:NSStringFromSelector(webDriverAttributesSelector)];
}

@end


Expand Down
1 change: 0 additions & 1 deletion WebDriverAgentLib/FBAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#import "FBSpringboardApplication.h"
#import "FBLogger.h"
#import "FBXCodeCompatibility.h"
#import "XCAXClient_iOS.h"
#import "XCElementSnapshot+FBHelpers.h"
#import "XCElementSnapshot.h"
#import "XCTestManager_ManagerInterface-Protocol.h"
Expand Down
Loading

0 comments on commit 1fb1117

Please sign in to comment.