Skip to content

Commit

Permalink
Handling tree command when no session is active
Browse files Browse the repository at this point in the history
Summary: Instead of grabbing acitve session we should grab active application

Reviewed By: gkassabli

Differential Revision: D3218778

fb-gh-sync-id: 53a593d99243fa154aa36925697f75b4e1866997
fbshipit-source-id: 53a593d99243fa154aa36925697f75b4e1866997
  • Loading branch information
Marek Cirkos authored and Facebook Github Bot 2 committed Apr 25, 2016
1 parent ad02d0f commit 1c4bb59
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions WebDriverAgentLib/Commands/FBDebugCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#import "FBElementTypeTransformer.h"
#import "FBRouteRequest.h"
#import "FBSession.h"
#import "XCAccessibilityElement.h"
#import "XCAXClient_iOS.h"
#import "XCUIElement+FBIsVisible.h"
#import "XCUIElement+WebDriverAttributes.h"
#import "XCUIElement.h"
Expand Down Expand Up @@ -42,8 +44,23 @@ + (NSArray *)routes

+ (id<FBResponsePayload>)handleGetActiveTreeCommand:(FBRouteRequest *)request
{
FBSession *session = [FBSession activeSession];
return [self handleTreeCommandWithParams:session.application];
FBApplication *application = [self activeApplication];
if (!application) {
return FBResponseDictionaryWithStatus(FBCommandStatusUnhandled, @"There is no active application");
}
return [self handleTreeCommandWithParams:application];
}

+ (FBApplication *)activeApplication
{
XCAccessibilityElement *activeApplicationElement = [[[XCAXClient_iOS sharedClient] activeApplications] firstObject];
if (!activeApplicationElement) {
return nil;
}
FBApplication *application = [FBApplication appWithPID:activeApplicationElement.processIdentifier];
[application query];
[application resolve];
return application;
}

+ (id<FBResponsePayload>)handleGetTreeCommand:(FBRouteRequest *)request
Expand Down

0 comments on commit 1c4bb59

Please sign in to comment.