Skip to content

Commit 271a015

Browse files
fix tests
1 parent 73c5cf1 commit 271a015

8 files changed

Lines changed: 9 additions & 49 deletions

File tree

WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
4949
*/
5050
- (id<FBXCElementSnapshot>)fb_customSnapshot;
5151

52-
/**
53-
Gets the most recent snapshot of the current element. The element will be
54-
automatically resolved if the snapshot is not available yet.
55-
Calls to this method mutate the `lastSnapshot` instance property..
56-
57-
@param maxDepth Allows to customize the maximum depth of the snapshot tree
58-
@return The recent snapshot of the element
59-
@throws FBStaleElementException if the element is not present in DOM and thus no snapshot could be made
60-
*/
61-
- (id<FBXCElementSnapshot>)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth;
62-
6352
/**
6453
Extracts the cached element snapshot from its query.
6554
No requests to the accessiblity framework is made.

WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,14 @@
4444

4545
@implementation XCUIElement (FBUtilities)
4646

47-
- (id<FBXCElementSnapshot>)fb_takeSnapshot:(BOOL)isCustom maxDepth:(nullable NSNumber *)maxDepth
47+
- (id<FBXCElementSnapshot>)fb_takeSnapshot:(BOOL)isCustom
4848
{
4949
__block id<FBXCElementSnapshot> snapshot = nil;
5050
@autoreleasepool {
5151
NSError *error = nil;
52-
if (isCustom) {
53-
int previousMaxDepth = FBConfiguration.snapshotMaxDepth;
54-
if (nil != maxDepth) {
55-
FBConfiguration.snapshotMaxDepth = maxDepth.unsignedIntValue;
56-
}
57-
snapshot = [self.fb_query fb_uniqueSnapshotWithError:&error];
58-
if (nil != maxDepth) {
59-
FBConfiguration.snapshotMaxDepth = previousMaxDepth;
60-
}
61-
} else {
62-
snapshot = (id<FBXCElementSnapshot>)[self snapshotWithError:&error];
63-
}
52+
snapshot = isCustom
53+
? [self.fb_query fb_uniqueSnapshotWithError:&error]
54+
: (id<FBXCElementSnapshot>)[self snapshotWithError:&error];
6455
if (nil == snapshot) {
6556
NSString *hintText = @"Make sure the application UI has the expected state";
6657
if (nil != error && [error.localizedDescription containsString:@"Identity Binding"]) {
@@ -80,17 +71,12 @@ @implementation XCUIElement (FBUtilities)
8071

8172
- (id<FBXCElementSnapshot>)fb_standardSnapshot
8273
{
83-
return [self fb_takeSnapshot:NO maxDepth:nil];
74+
return [self fb_takeSnapshot:NO];
8475
}
8576

8677
- (id<FBXCElementSnapshot>)fb_customSnapshot
8778
{
88-
return [self fb_takeSnapshot:YES maxDepth:nil];
89-
}
90-
91-
- (id<FBXCElementSnapshot>)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth
92-
{
93-
return [self fb_takeSnapshot:YES maxDepth:@(maxDepth)];
79+
return [self fb_takeSnapshot:YES];
9480
}
9581

9682
- (id<FBXCElementSnapshot>)fb_cachedSnapshot

WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ @implementation XCUIElement (WebDriverAttributesForwarding)
2828

2929
- (id<FBXCElementSnapshot>)fb_snapshotForAttributeName:(NSString *)name
3030
{
31-
BOOL isValueRequest = [name isEqualToString:FBStringify(XCUIElement, wdValue)];
32-
// https://github.com/appium/appium-xcuitest-driver/issues/2552
33-
if (isValueRequest) {
34-
return [self fb_customSnapshotWithMaxDepth:1];
35-
}
3631
BOOL isCustomSnapshot = ![self isKindOfClass:XCUIApplication.class]
3732
|| [name isEqualToString:FBStringify(XCUIElement, isWDAccessible)]
3833
|| [name isEqualToString:FBStringify(XCUIElement, isWDAccessibilityContainer)]
34+
// https://github.com/appium/appium-xcuitest-driver/issues/2552
35+
|| [name isEqualToString:FBStringify(XCUIElement, wdValue)]
3936
|| [name isEqualToString:FBStringify(XCUIElement, wdIndex)];
4037
return isCustomSnapshot ? [self fb_customSnapshot] : [self fb_standardSnapshot];
4138
}

WebDriverAgentLib/Commands/FBElementCommands.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ + (NSArray *)routes
152152
FBElementCache *elementCache = request.session.elementCache;
153153
XCUIElement *element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
154154
// https://github.com/appium/appium-xcuitest-driver/issues/2552
155-
id<FBXCElementSnapshot> snapshot = [element fb_customSnapshotWithMaxDepth:1];
155+
id<FBXCElementSnapshot> snapshot = [element fb_customSnapshot];
156156
FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
157157
id text = FBFirstNonEmptyValue(wrappedSnapshot.wdValue, wrappedSnapshot.wdLabel);
158158
return FBResponseWithObject(text ?: @"");

WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
- (void)resolve;
4242
- (id _Nonnull)fb_standardSnapshot;
4343
- (id _Nonnull)fb_customSnapshot;
44-
- (id _Nonnull)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth;
4544
- (nullable id)query;
4645

4746
// Checks

WebDriverAgentTests/UnitTests/Doubles/XCUIElementDouble.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ - (id _Nonnull)fb_customSnapshot;
7979
return [self lastSnapshot];
8080
}
8181

82-
- (id _Nonnull)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth
83-
{
84-
return [self lastSnapshot];
85-
}
86-
8782
- (NSString *)fb_cacheId
8883
{
8984
return self.wdUID;

WebDriverAgentTests/UnitTests_tvOS/Doubles/XCUIElementDouble.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
- (void)resolve;
4040
- (id _Nonnull)fb_standardSnapshot;
4141
- (id _Nonnull)fb_customSnapshot;
42-
- (id _Nonnull)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth;
4342

4443
// Checks
4544
@property (nonatomic, assign, readonly) BOOL didResolve;

WebDriverAgentTests/UnitTests_tvOS/Doubles/XCUIElementDouble.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ - (id)fb_customSnapshot
6262
return [self lastSnapshot];
6363
}
6464

65-
- (id _Nonnull)fb_customSnapshotWithMaxDepth:(NSUInteger)maxDepth
66-
{
67-
return [self lastSnapshot];
68-
}
69-
7065
- (void)resolve
7166
{
7267
self.didResolve = YES;

0 commit comments

Comments
 (0)