Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions WebDriverAgentLib/Commands/FBCustomCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ + (NSArray *)routes
[[FBRoute POST:@"/wda/homescreen"].withoutSession respondWithTarget:self action:@selector(handleHomescreenCommand:)],
[[FBRoute POST:@"/wda/deactivateApp"] respondWithTarget:self action:@selector(handleDeactivateAppCommand:)],
[[FBRoute POST:@"/wda/keyboard/dismiss"] respondWithTarget:self action:@selector(handleDismissKeyboardCommand:)],
[[FBRoute GET:@"/wda/elementCache/size"] respondWithTarget:self action:@selector(handleGetElementCacheSizeCommand:)],
[[FBRoute POST:@"/wda/elementCache/clear"] respondWithTarget:self action:@selector(handleClearElementCacheCommand:)],
];
}

Expand Down Expand Up @@ -93,4 +95,16 @@ + (NSArray *)routes
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)handleGetElementCacheSizeCommand:(FBRouteRequest *)request
{
NSNumber *count = [NSNumber numberWithUnsignedInteger:[request.session.elementCache count]];
return FBResponseWithObject(count);
}

+ (id<FBResponsePayload>)handleClearElementCacheCommand:(FBRouteRequest *)request
{
FBElementCache *elementCache = request.session.elementCache;
[elementCache clear];
return FBResponseWithOK();
}
@end
9 changes: 9 additions & 0 deletions WebDriverAgentLib/Routing/FBElementCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (nullable XCUIElement *)elementForUUID:(NSString *__nullable)uuid;

/**
Clears the cache
*/
- (void)clear;

/**
Gets the number of elements in the cache
*/
@property (nonatomic, readonly) NSUInteger count;
@end

NS_ASSUME_NONNULL_END
9 changes: 9 additions & 0 deletions WebDriverAgentLib/Routing/FBElementCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,13 @@ - (XCUIElement *)elementForUUID:(NSString *)uuid
return element;
}

- (void)clear
{
[self.elementCache removeAllObjects];
}

- (NSUInteger)count
{
return [self.elementCache count];
}
@end