diff --git a/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h b/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h index b868e1cc6..e60efaa48 100644 --- a/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h +++ b/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h @@ -174,7 +174,8 @@ typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) { Only works since Xcode 14.3/iOS 16.4 @param error If there is an error, upon return contains an NSError object that describes the problem. - @return The current simulated location or nil in case of failure + @return The current simulated location or nil in case of failure or if no location has previously been seet + (the returned error will be nil in the latter case) */ - (nullable CLLocation *)fb_getSimulatedLocation:(NSError **)error; diff --git a/WebDriverAgentLib/Commands/FBCustomCommands.m b/WebDriverAgentLib/Commands/FBCustomCommands.m index d9f24d6dd..6fd41d6a4 100644 --- a/WebDriverAgentLib/Commands/FBCustomCommands.m +++ b/WebDriverAgentLib/Commands/FBCustomCommands.m @@ -503,14 +503,14 @@ + (NSString *)timeZone { NSError *error; CLLocation *location = [XCUIDevice.sharedDevice fb_getSimulatedLocation:&error]; - if (nil == location) { + if (nil != error) { return FBResponseWithStatus([FBCommandStatus unknownErrorWithMessage:error.description traceback:nil]); } return FBResponseWithObject(@{ - @"latitude": @(location.coordinate.latitude), - @"longiture": @(location.coordinate.longitude), - @"altitude": @(location.altitude), + @"latitude": location ? @(location.coordinate.latitude) : NSNull.null, + @"longitude": location ? @(location.coordinate.longitude) : NSNull.null, + @"altitude": location ? @(location.altitude) : NSNull.null, }); }