appium-webdriveragent 5.15.7 → 5.15.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/PrivateHeaders/XCTest/XCUIApplication.h +1 -0
- package/WebDriverAgent.xcodeproj/project.pbxproj +18 -6
- package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/kazu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/WebDriverAgent.xcodeproj/xcuserdata/kazu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +1342 -0
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +0 -38
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +5 -148
- package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +1 -1
- package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.h +1 -0
- package/WebDriverAgentLib/Categories/XCUIDevice+FBRotation.m +3 -5
- package/WebDriverAgentLib/Categories/XCUIElement+FBTVFocuse.m +2 -2
- package/WebDriverAgentLib/Commands/FBAlertViewCommands.m +4 -4
- package/WebDriverAgentLib/Commands/FBCustomCommands.m +2 -2
- package/WebDriverAgentLib/Commands/FBDebugCommands.m +3 -2
- package/WebDriverAgentLib/Commands/FBElementCommands.m +4 -2
- package/WebDriverAgentLib/Commands/FBFindElementCommands.m +1 -0
- package/WebDriverAgentLib/Commands/FBOrientationCommands.m +8 -9
- package/WebDriverAgentLib/Commands/FBSessionCommands.m +9 -7
- package/WebDriverAgentLib/Commands/FBTouchActionCommands.m +1 -0
- package/WebDriverAgentLib/FBAlert.m +3 -3
- package/WebDriverAgentLib/FBApplication.h +49 -0
- package/WebDriverAgentLib/FBApplication.m +185 -0
- package/WebDriverAgentLib/Routing/FBSession.h +14 -13
- package/WebDriverAgentLib/Routing/FBSession.m +46 -49
- package/WebDriverAgentLib/Utilities/FBAlertsMonitor.m +3 -3
- package/WebDriverAgentLib/Utilities/FBKeyboard.m +5 -6
- package/WebDriverAgentLib/Utilities/FBMjpegServer.m +1 -0
- package/WebDriverAgentLib/Utilities/FBPasteboard.m +2 -2
- package/WebDriverAgentLib/Utilities/FBScreen.m +2 -1
- package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +2 -1
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +33 -0
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +40 -2
- package/WebDriverAgentLib/WebDriverAgentLib.h +1 -0
- package/WebDriverAgentTests/IntegrationTests/FBAutoAlertsHandlerTests.m +3 -2
- package/WebDriverAgentTests/IntegrationTests/FBElementVisibilityTests.m +1 -0
- package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.h +3 -1
- package/WebDriverAgentTests/IntegrationTests/FBIntegrationTestCase.m +5 -5
- package/WebDriverAgentTests/IntegrationTests/FBSafariAlertTests.m +2 -1
- package/WebDriverAgentTests/IntegrationTests/FBSessionIntegrationTests.m +10 -11
- package/WebDriverAgentTests/IntegrationTests/FBTapTest.m +1 -0
- package/WebDriverAgentTests/IntegrationTests/FBW3CMultiTouchActionsIntegrationTests.m +1 -0
- package/WebDriverAgentTests/IntegrationTests/XCUIApplicationHelperTests.m +8 -8
- package/WebDriverAgentTests/IntegrationTests/XCUIDeviceHelperTests.m +4 -5
- package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +1 -0
- package/WebDriverAgentTests/UnitTests/Doubles/{XCUIApplicationDouble.h → FBApplicationDouble.h} +1 -1
- package/WebDriverAgentTests/UnitTests/Doubles/{XCUIApplicationDouble.m → FBApplicationDouble.m} +3 -3
- package/WebDriverAgentTests/UnitTests/FBSessionTests.m +3 -3
- package/build/lib/utils.d.ts +2 -2
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +7 -5
- package/build/lib/utils.js.map +1 -1
- package/lib/utils.js +7 -5
- package/package.json +1 -1
|
@@ -122,44 +122,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
122
122
|
*/
|
|
123
123
|
- (nullable NSArray<NSDictionary<NSString *, NSString*> *> *)fb_performAccessibilityAuditWithAuditTypes:(uint64_t)auditTypes
|
|
124
124
|
error:(NSError **)error;
|
|
125
|
-
/**
|
|
126
|
-
Constructor used to get current active application
|
|
127
|
-
*/
|
|
128
|
-
+ (instancetype)fb_activeApplication;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
Constructor used to get current active application
|
|
132
|
-
|
|
133
|
-
@param bundleId The bundle identifier of an app, which should be selected as active by default
|
|
134
|
-
if it is present in the list of active applications
|
|
135
|
-
*/
|
|
136
|
-
+ (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
Constructor used to get the system application (e.g. Springboard on iOS)
|
|
140
|
-
*/
|
|
141
|
-
+ (instancetype)fb_systemApplication;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
Retrieves the list of all currently active applications
|
|
145
|
-
*/
|
|
146
|
-
+ (NSArray<XCUIApplication *> *)fb_activeApplications;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
Switch to system app (called Springboard on iOS)
|
|
150
|
-
|
|
151
|
-
@param error If there is an error, upon return contains an NSError object that describes the problem.
|
|
152
|
-
@return YES if the operation succeeds, otherwise NO.
|
|
153
|
-
*/
|
|
154
|
-
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
Determines whether the other app is the same as the current one
|
|
158
|
-
|
|
159
|
-
@param otherApp Other app instance
|
|
160
|
-
@return YES if the other app has the same identifier
|
|
161
|
-
*/
|
|
162
|
-
- (BOOL)fb_isSameAppAs:(nullable XCUIApplication *)otherApp;
|
|
163
125
|
|
|
164
126
|
@end
|
|
165
127
|
|
|
@@ -9,14 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
#import "XCUIApplication+FBHelpers.h"
|
|
11
11
|
|
|
12
|
-
#import "FBActiveAppDetectionPoint.h"
|
|
13
12
|
#import "FBElementTypeTransformer.h"
|
|
14
13
|
#import "FBKeyboard.h"
|
|
15
14
|
#import "FBLogger.h"
|
|
16
15
|
#import "FBExceptions.h"
|
|
17
16
|
#import "FBMacros.h"
|
|
18
17
|
#import "FBMathUtils.h"
|
|
19
|
-
#import "
|
|
18
|
+
#import "FBActiveAppDetectionPoint.h"
|
|
20
19
|
#import "FBXCodeCompatibility.h"
|
|
21
20
|
#import "FBXPath.h"
|
|
22
21
|
#import "FBXCAccessibilityElement.h"
|
|
@@ -24,19 +23,14 @@
|
|
|
24
23
|
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
25
24
|
#import "FBXCAXClientProxy.h"
|
|
26
25
|
#import "FBXMLGenerationOptions.h"
|
|
27
|
-
#import "XCTestManager_ManagerInterface-Protocol.h"
|
|
28
|
-
#import "XCTestPrivateSymbols.h"
|
|
29
|
-
#import "XCTRunnerDaemonSession.h"
|
|
30
|
-
#import "XCUIApplication.h"
|
|
31
|
-
#import "XCUIApplicationImpl.h"
|
|
32
|
-
#import "XCUIApplicationProcess.h"
|
|
33
26
|
#import "XCUIDevice+FBHelpers.h"
|
|
34
|
-
#import "XCUIElement.h"
|
|
35
27
|
#import "XCUIElement+FBCaching.h"
|
|
36
28
|
#import "XCUIElement+FBIsVisible.h"
|
|
37
29
|
#import "XCUIElement+FBUtilities.h"
|
|
38
30
|
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
39
|
-
#import "
|
|
31
|
+
#import "XCTestManager_ManagerInterface-Protocol.h"
|
|
32
|
+
#import "XCTestPrivateSymbols.h"
|
|
33
|
+
#import "XCTRunnerDaemonSession.h"
|
|
40
34
|
|
|
41
35
|
static NSString* const FBUnknownBundleId = @"unknown";
|
|
42
36
|
|
|
@@ -147,7 +141,7 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
|
|
|
147
141
|
return NO;
|
|
148
142
|
}
|
|
149
143
|
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:MAX(duration, .0)]];
|
|
150
|
-
[self
|
|
144
|
+
[self fb_activate];
|
|
151
145
|
return YES;
|
|
152
146
|
}
|
|
153
147
|
|
|
@@ -399,141 +393,4 @@ NSDictionary<NSNumber *, NSString *> *auditTypeValuesToNames(void) {
|
|
|
399
393
|
return isSuccessful ? resultArray.copy : nil;
|
|
400
394
|
}
|
|
401
395
|
|
|
402
|
-
+ (instancetype)fb_activeApplication
|
|
403
|
-
{
|
|
404
|
-
return [self fb_activeApplicationWithDefaultBundleId:nil];
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
+ (NSArray<XCUIApplication *> *)fb_activeApplications
|
|
408
|
-
{
|
|
409
|
-
NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
|
|
410
|
-
NSMutableArray<XCUIApplication *> *result = [NSMutableArray array];
|
|
411
|
-
if (activeApplicationElements.count > 0) {
|
|
412
|
-
for (id<FBXCAccessibilityElement> applicationElement in activeApplicationElements) {
|
|
413
|
-
XCUIApplication *app = [XCUIApplication fb_applicationWithPID:applicationElement.processIdentifier];
|
|
414
|
-
if (nil != app) {
|
|
415
|
-
[result addObject:app];
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
return result.count > 0 ? result.copy : @[self.class.fb_systemApplication];
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
+ (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId
|
|
423
|
-
{
|
|
424
|
-
NSArray<id<FBXCAccessibilityElement>> *activeApplicationElements = [FBXCAXClientProxy.sharedClient activeApplications];
|
|
425
|
-
id<FBXCAccessibilityElement> activeApplicationElement = nil;
|
|
426
|
-
id<FBXCAccessibilityElement> currentElement = nil;
|
|
427
|
-
if (nil != bundleId) {
|
|
428
|
-
currentElement = FBActiveAppDetectionPoint.sharedInstance.axElement;
|
|
429
|
-
if (nil != currentElement) {
|
|
430
|
-
NSArray<NSDictionary *> *appInfos = [self fb_appsInfoWithAxElements:@[currentElement]];
|
|
431
|
-
[FBLogger logFmt:@"Detected on-screen application: %@", appInfos.firstObject[@"bundleId"]];
|
|
432
|
-
if ([[appInfos.firstObject objectForKey:@"bundleId"] isEqualToString:(id)bundleId]) {
|
|
433
|
-
activeApplicationElement = currentElement;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
if (nil == activeApplicationElement && activeApplicationElements.count > 1) {
|
|
438
|
-
if (nil != bundleId) {
|
|
439
|
-
NSArray<NSDictionary *> *appInfos = [self fb_appsInfoWithAxElements:activeApplicationElements];
|
|
440
|
-
NSMutableArray<NSString *> *bundleIds = [NSMutableArray array];
|
|
441
|
-
for (NSDictionary *appInfo in appInfos) {
|
|
442
|
-
[bundleIds addObject:(NSString *)appInfo[@"bundleId"]];
|
|
443
|
-
}
|
|
444
|
-
[FBLogger logFmt:@"Detected system active application(s): %@", bundleIds];
|
|
445
|
-
// Try to select the desired application first
|
|
446
|
-
for (NSUInteger appIdx = 0; appIdx < appInfos.count; appIdx++) {
|
|
447
|
-
if ([[[appInfos objectAtIndex:appIdx] objectForKey:@"bundleId"] isEqualToString:(id)bundleId]) {
|
|
448
|
-
activeApplicationElement = [activeApplicationElements objectAtIndex:appIdx];
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
// Fall back to the "normal" algorithm if the desired application is either
|
|
454
|
-
// not set or is not active
|
|
455
|
-
if (nil == activeApplicationElement) {
|
|
456
|
-
if (nil == currentElement) {
|
|
457
|
-
currentElement = FBActiveAppDetectionPoint.sharedInstance.axElement;
|
|
458
|
-
}
|
|
459
|
-
if (nil == currentElement) {
|
|
460
|
-
[FBLogger log:@"Cannot precisely detect the current application. Will use the system's recently active one"];
|
|
461
|
-
if (nil == bundleId) {
|
|
462
|
-
[FBLogger log:@"Consider changing the 'defaultActiveApplication' setting to the bundle identifier of the desired application under test"];
|
|
463
|
-
}
|
|
464
|
-
} else {
|
|
465
|
-
for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
|
|
466
|
-
if (appElement.processIdentifier == currentElement.processIdentifier) {
|
|
467
|
-
activeApplicationElement = appElement;
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
if (nil != activeApplicationElement) {
|
|
476
|
-
XCUIApplication *application = [XCUIApplication fb_applicationWithPID:activeApplicationElement.processIdentifier];
|
|
477
|
-
if (nil != application) {
|
|
478
|
-
return application;
|
|
479
|
-
}
|
|
480
|
-
[FBLogger log:@"Cannot translate the active process identifier into an application object"];
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
if (activeApplicationElements.count > 0) {
|
|
484
|
-
[FBLogger logFmt:@"Getting the most recent active application (out of %@ total items)", @(activeApplicationElements.count)];
|
|
485
|
-
for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
|
|
486
|
-
XCUIApplication *application = [XCUIApplication fb_applicationWithPID:appElement.processIdentifier];
|
|
487
|
-
if (nil != application) {
|
|
488
|
-
return application;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
[FBLogger log:@"Cannot retrieve any active applications. Assuming the system application is the active one"];
|
|
494
|
-
return [self fb_systemApplication];
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
+ (instancetype)fb_systemApplication
|
|
498
|
-
{
|
|
499
|
-
return [self fb_applicationWithPID:
|
|
500
|
-
[[FBXCAXClientProxy.sharedClient systemApplication] processIdentifier]];
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
+ (instancetype)fb_applicationWithPID:(pid_t)processID
|
|
504
|
-
{
|
|
505
|
-
return [FBXCAXClientProxy.sharedClient monitoredApplicationWithProcessIdentifier:processID];
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error
|
|
509
|
-
{
|
|
510
|
-
XCUIApplication *systemApp = self.fb_systemApplication;
|
|
511
|
-
@try {
|
|
512
|
-
if (!systemApp.running) {
|
|
513
|
-
[systemApp launch];
|
|
514
|
-
} else {
|
|
515
|
-
[systemApp activate];
|
|
516
|
-
}
|
|
517
|
-
} @catch (NSException *e) {
|
|
518
|
-
return [[[FBErrorBuilder alloc]
|
|
519
|
-
withDescription:nil == e ? @"Cannot open the home screen" : e.reason]
|
|
520
|
-
buildError:error];
|
|
521
|
-
}
|
|
522
|
-
return [[[[FBRunLoopSpinner new]
|
|
523
|
-
timeout:5]
|
|
524
|
-
timeoutErrorMessage:@"Timeout waiting until the home screen is visible"]
|
|
525
|
-
spinUntilTrue:^BOOL{
|
|
526
|
-
return [systemApp fb_isSameAppAs:self.fb_activeApplication];
|
|
527
|
-
}
|
|
528
|
-
error:error];
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
- (BOOL)fb_isSameAppAs:(nullable XCUIApplication *)otherApp
|
|
532
|
-
{
|
|
533
|
-
if (nil == otherApp) {
|
|
534
|
-
return NO;
|
|
535
|
-
}
|
|
536
|
-
return [self.bundleID isEqualToString:(NSString *)otherApp.bundleID];
|
|
537
|
-
}
|
|
538
|
-
|
|
539
396
|
@end
|
|
@@ -56,7 +56,7 @@ static bool fb_isLocked;
|
|
|
56
56
|
|
|
57
57
|
- (BOOL)fb_goToHomescreenWithError:(NSError **)error
|
|
58
58
|
{
|
|
59
|
-
return [
|
|
59
|
+
return [FBApplication fb_switchToSystemApplicationWithError:error];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
- (BOOL)fb_lockScreen:(NSError **)error
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
#import "XCUIDevice+FBRotation.h"
|
|
11
11
|
|
|
12
12
|
#import "FBConfiguration.h"
|
|
13
|
-
#import "XCUIApplication.h"
|
|
14
|
-
#import "XCUIApplication+FBHelpers.h"
|
|
15
13
|
#import "XCUIElement+FBUtilities.h"
|
|
16
14
|
|
|
17
15
|
# if !TARGET_OS_TV
|
|
@@ -20,7 +18,7 @@
|
|
|
20
18
|
|
|
21
19
|
- (BOOL)fb_setDeviceInterfaceOrientation:(UIDeviceOrientation)orientation
|
|
22
20
|
{
|
|
23
|
-
|
|
21
|
+
FBApplication *application = FBApplication.fb_activeApplication;
|
|
24
22
|
[XCUIDevice sharedDevice].orientation = orientation;
|
|
25
23
|
return [self waitUntilInterfaceIsAtOrientation:orientation application:application];
|
|
26
24
|
}
|
|
@@ -32,12 +30,12 @@
|
|
|
32
30
|
return NO;
|
|
33
31
|
}
|
|
34
32
|
NSInteger orientation = keysForRotationObj.firstObject.integerValue;
|
|
35
|
-
|
|
33
|
+
FBApplication *application = FBApplication.fb_activeApplication;
|
|
36
34
|
[XCUIDevice sharedDevice].orientation = orientation;
|
|
37
35
|
return [self waitUntilInterfaceIsAtOrientation:orientation application:application];
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
- (BOOL)waitUntilInterfaceIsAtOrientation:(NSInteger)orientation application:(
|
|
38
|
+
- (BOOL)waitUntilInterfaceIsAtOrientation:(NSInteger)orientation application:(FBApplication *)application
|
|
41
39
|
{
|
|
42
40
|
// Tapping elements immediately after rotation may fail due to way UIKit is handling touches.
|
|
43
41
|
// We should wait till UI cools off, before continuing
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
#import "XCUIElement+FBTVFocuse.h"
|
|
11
11
|
|
|
12
12
|
#import <XCTest/XCUIRemote.h>
|
|
13
|
+
#import "FBApplication.h"
|
|
13
14
|
#import "FBConfiguration.h"
|
|
14
15
|
#import "FBErrorBuilder.h"
|
|
15
16
|
#import <FBTVNavigationTracker.h>
|
|
16
|
-
#import "XCUIApplication+FBHelpers.h"
|
|
17
17
|
#import "XCUIElement+FBUtilities.h"
|
|
18
18
|
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
19
19
|
|
|
@@ -25,7 +25,7 @@ int const MAX_ITERATIONS_COUNT = 100;
|
|
|
25
25
|
|
|
26
26
|
- (BOOL)fb_setFocusWithError:(NSError**) error
|
|
27
27
|
{
|
|
28
|
-
[
|
|
28
|
+
[FBApplication.fb_activeApplication fb_waitUntilStableWithTimeout:FBConfiguration.animationCoolOffTimeout];
|
|
29
29
|
|
|
30
30
|
if (!self.wdEnabled) {
|
|
31
31
|
if (error) {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
#import "FBAlertViewCommands.h"
|
|
11
11
|
|
|
12
12
|
#import "FBAlert.h"
|
|
13
|
+
#import "FBApplication.h"
|
|
13
14
|
#import "FBRouteRequest.h"
|
|
14
15
|
#import "FBSession.h"
|
|
15
|
-
#import "XCUIApplication+FBHelpers.h"
|
|
16
16
|
|
|
17
17
|
@implementation FBAlertViewCommands
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
+ (id<FBResponsePayload>)handleAlertGetTextCommand:(FBRouteRequest *)request
|
|
40
40
|
{
|
|
41
|
-
|
|
41
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
42
42
|
NSString *alertText = [FBAlert alertWithApplication:application].text;
|
|
43
43
|
if (!alertText) {
|
|
44
44
|
return FBResponseWithStatus([FBCommandStatus noAlertOpenErrorWithMessage:nil
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
|
|
74
74
|
+ (id<FBResponsePayload>)handleAlertAcceptCommand:(FBRouteRequest *)request
|
|
75
75
|
{
|
|
76
|
-
|
|
76
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
77
77
|
NSString *name = request.arguments[@"name"];
|
|
78
78
|
FBAlert *alert = [FBAlert alertWithApplication:application];
|
|
79
79
|
NSError *error;
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
|
|
97
97
|
+ (id<FBResponsePayload>)handleAlertDismissCommand:(FBRouteRequest *)request
|
|
98
98
|
{
|
|
99
|
-
|
|
99
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
100
100
|
NSString *name = request.arguments[@"name"];
|
|
101
101
|
FBAlert *alert = [FBAlert alertWithApplication:application];
|
|
102
102
|
NSError *error;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#import <XCTest/XCUIDevice.h>
|
|
13
13
|
#import <CoreLocation/CoreLocation.h>
|
|
14
14
|
|
|
15
|
+
#import "FBApplication.h"
|
|
15
16
|
#import "FBConfiguration.h"
|
|
16
17
|
#import "FBKeyboard.h"
|
|
17
18
|
#import "FBNotificationsHelper.h"
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
#import "FBScreen.h"
|
|
24
25
|
#import "FBSession.h"
|
|
25
26
|
#import "FBXCodeCompatibility.h"
|
|
26
|
-
#import "XCUIApplication.h"
|
|
27
27
|
#import "XCUIApplication+FBHelpers.h"
|
|
28
28
|
#import "XCUIDevice+FBHelpers.h"
|
|
29
29
|
#import "XCUIElement.h"
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
|
|
172
172
|
+ (id<FBResponsePayload>)handleActiveAppInfo:(FBRouteRequest *)request
|
|
173
173
|
{
|
|
174
|
-
XCUIApplication *app = request.session.activeApplication ?:
|
|
174
|
+
XCUIApplication *app = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
175
175
|
return FBResponseWithObject(@{
|
|
176
176
|
@"pid": @(app.processID),
|
|
177
177
|
@"bundleId": app.bundleID,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBDebugCommands.h"
|
|
11
11
|
|
|
12
|
+
#import "FBApplication.h"
|
|
12
13
|
#import "FBRouteRequest.h"
|
|
13
14
|
#import "FBSession.h"
|
|
14
15
|
#import "FBXMLGenerationOptions.h"
|
|
@@ -41,7 +42,7 @@ static NSString *const SOURCE_FORMAT_DESCRIPTION = @"description";
|
|
|
41
42
|
+ (id<FBResponsePayload>)handleGetSourceCommand:(FBRouteRequest *)request
|
|
42
43
|
{
|
|
43
44
|
// This method might be called without session
|
|
44
|
-
|
|
45
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
45
46
|
NSString *sourceType = request.parameters[@"format"] ?: SOURCE_FORMAT_XML;
|
|
46
47
|
NSString *sourceScope = request.parameters[@"scope"];
|
|
47
48
|
id result;
|
|
@@ -70,7 +71,7 @@ static NSString *const SOURCE_FORMAT_DESCRIPTION = @"description";
|
|
|
70
71
|
+ (id<FBResponsePayload>)handleGetAccessibleSourceCommand:(FBRouteRequest *)request
|
|
71
72
|
{
|
|
72
73
|
// This method might be called without session
|
|
73
|
-
|
|
74
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
74
75
|
return FBResponseWithObject(application.fb_accessibilityTree ?: @{});
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBElementCommands.h"
|
|
11
11
|
|
|
12
|
+
#import "FBApplication.h"
|
|
12
13
|
#import "FBConfiguration.h"
|
|
13
14
|
#import "FBKeyboard.h"
|
|
14
15
|
#import "FBRoute.h"
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
#import "FBElementCache.h"
|
|
18
19
|
#import "FBErrorBuilder.h"
|
|
19
20
|
#import "FBSession.h"
|
|
21
|
+
#import "FBApplication.h"
|
|
20
22
|
#import "FBElementUtils.h"
|
|
21
23
|
#import "FBMacros.h"
|
|
22
24
|
#import "FBMathUtils.h"
|
|
@@ -527,7 +529,7 @@
|
|
|
527
529
|
{
|
|
528
530
|
XCUIElement *element = nil;
|
|
529
531
|
if (nil == request.parameters[@"uuid"]) {
|
|
530
|
-
element =
|
|
532
|
+
element = [FBApplication fb_activeApplication];
|
|
531
533
|
} else {
|
|
532
534
|
FBElementCache *elementCache = request.session.elementCache;
|
|
533
535
|
element = [elementCache elementForUUID:(NSString *)request.parameters[@"uuid"]];
|
|
@@ -565,7 +567,7 @@
|
|
|
565
567
|
|
|
566
568
|
+ (id<FBResponsePayload>)handleGetWindowSize:(FBRouteRequest *)request
|
|
567
569
|
{
|
|
568
|
-
XCUIApplication *app = request.session.activeApplication ?:
|
|
570
|
+
XCUIApplication *app = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
569
571
|
|
|
570
572
|
#if TARGET_OS_TV
|
|
571
573
|
CGSize screenSize = app.frame.size;
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
#import "FBRouteRequest.h"
|
|
13
13
|
#import "FBMacros.h"
|
|
14
14
|
#import "FBSession.h"
|
|
15
|
-
#import "
|
|
16
|
-
#import "XCUIApplication+FBHelpers.h"
|
|
15
|
+
#import "FBApplication.h"
|
|
17
16
|
#import "XCUIDevice.h"
|
|
18
17
|
|
|
19
18
|
extern const struct FBWDOrientationValues {
|
|
@@ -56,14 +55,14 @@ const struct FBWDOrientationValues FBWDOrientationValues = {
|
|
|
56
55
|
|
|
57
56
|
+ (id<FBResponsePayload>)handleGetOrientation:(FBRouteRequest *)request
|
|
58
57
|
{
|
|
59
|
-
|
|
58
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
60
59
|
NSString *orientation = [self.class interfaceOrientationForApplication:application];
|
|
61
60
|
return FBResponseWithObject([[self _wdOrientationsMapping] objectForKey:orientation]);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
+ (id<FBResponsePayload>)handleSetOrientation:(FBRouteRequest *)request
|
|
65
64
|
{
|
|
66
|
-
|
|
65
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
67
66
|
if ([self.class setDeviceOrientation:request.arguments[@"orientation"] forApplication:application]) {
|
|
68
67
|
return FBResponseWithOK();
|
|
69
68
|
}
|
|
@@ -74,7 +73,7 @@ const struct FBWDOrientationValues FBWDOrientationValues = {
|
|
|
74
73
|
+ (id<FBResponsePayload>)handleGetRotation:(FBRouteRequest *)request
|
|
75
74
|
{
|
|
76
75
|
XCUIDevice *device = [XCUIDevice sharedDevice];
|
|
77
|
-
|
|
76
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
78
77
|
UIInterfaceOrientation orientation = application.interfaceOrientation;
|
|
79
78
|
return FBResponseWithObject(device.fb_rotationMapping[@(orientation)]);
|
|
80
79
|
}
|
|
@@ -102,7 +101,7 @@ const struct FBWDOrientationValues FBWDOrientationValues = {
|
|
|
102
101
|
traceback:nil]);
|
|
103
102
|
}
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
|
|
106
105
|
if (![self.class setDeviceRotation:request.arguments forApplication:application]) {
|
|
107
106
|
NSString *errMessage = [
|
|
108
107
|
NSString stringWithFormat:@"The current rotation cannot be set to %@. Make sure the %@ application supports it",
|
|
@@ -117,7 +116,7 @@ const struct FBWDOrientationValues FBWDOrientationValues = {
|
|
|
117
116
|
|
|
118
117
|
#pragma mark - Helpers
|
|
119
118
|
|
|
120
|
-
+ (NSString *)interfaceOrientationForApplication:(
|
|
119
|
+
+ (NSString *)interfaceOrientationForApplication:(FBApplication *)application
|
|
121
120
|
{
|
|
122
121
|
NSNumber *orientation = @(application.interfaceOrientation);
|
|
123
122
|
NSSet *keys = [[self _orientationsMapping] keysOfEntriesPassingTest:^BOOL(id key, NSNumber *obj, BOOL *stop) {
|
|
@@ -129,12 +128,12 @@ const struct FBWDOrientationValues FBWDOrientationValues = {
|
|
|
129
128
|
return keys.anyObject;
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
+ (BOOL)setDeviceRotation:(NSDictionary *)rotationObj forApplication:(
|
|
131
|
+
+ (BOOL)setDeviceRotation:(NSDictionary *)rotationObj forApplication:(FBApplication *)application
|
|
133
132
|
{
|
|
134
133
|
return [[XCUIDevice sharedDevice] fb_setDeviceRotation:rotationObj];
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
+ (BOOL)setDeviceOrientation:(NSString *)orientation forApplication:(
|
|
136
|
+
+ (BOOL)setDeviceOrientation:(NSString *)orientation forApplication:(FBApplication *)application
|
|
138
137
|
{
|
|
139
138
|
NSNumber *orientationValue = [[self _orientationsMapping] objectForKey:[orientation uppercaseString]];
|
|
140
139
|
if (orientationValue == nil) {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBSessionCommands.h"
|
|
11
11
|
|
|
12
|
+
#import "FBApplication.h"
|
|
12
13
|
#import "FBCapabilities.h"
|
|
13
14
|
#import "FBConfiguration.h"
|
|
14
15
|
#import "FBLogger.h"
|
|
@@ -16,6 +17,7 @@
|
|
|
16
17
|
#import "FBRouteRequest.h"
|
|
17
18
|
#import "FBSession.h"
|
|
18
19
|
#import "FBSettings.h"
|
|
20
|
+
#import "FBApplication.h"
|
|
19
21
|
#import "FBRuntimeUtils.h"
|
|
20
22
|
#import "FBActiveAppDetectionPoint.h"
|
|
21
23
|
#import "FBXCodeCompatibility.h"
|
|
@@ -136,15 +138,15 @@
|
|
|
136
138
|
}
|
|
137
139
|
|
|
138
140
|
NSString *bundleID = capabilities[FB_CAP_BUNDLE_ID];
|
|
139
|
-
|
|
141
|
+
FBApplication *app = nil;
|
|
140
142
|
if (bundleID != nil) {
|
|
141
|
-
app = [[
|
|
143
|
+
app = [[FBApplication alloc] initWithBundleIdentifier:bundleID];
|
|
142
144
|
BOOL forceAppLaunch = YES;
|
|
143
145
|
if (nil != capabilities[FB_CAP_FORCE_APP_LAUNCH]) {
|
|
144
146
|
forceAppLaunch = [capabilities[FB_CAP_FORCE_APP_LAUNCH] boolValue];
|
|
145
147
|
}
|
|
146
|
-
|
|
147
|
-
BOOL isAppRunning = appState >=
|
|
148
|
+
NSUInteger appState = [app fb_state];
|
|
149
|
+
BOOL isAppRunning = appState >= 2;
|
|
148
150
|
if (!isAppRunning || (isAppRunning && forceAppLaunch)) {
|
|
149
151
|
app.fb_shouldWaitForQuiescence = nil == capabilities[FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE]
|
|
150
152
|
|| [capabilities[FB_CAP_SHOULD_WAIT_FOR_QUIESCENCE] boolValue];
|
|
@@ -156,8 +158,8 @@
|
|
|
156
158
|
return FBResponseWithStatus([FBCommandStatus sessionNotCreatedError:errorMsg
|
|
157
159
|
traceback:nil]);
|
|
158
160
|
}
|
|
159
|
-
} else if (appState
|
|
160
|
-
[app
|
|
161
|
+
} else if (appState < 4 && !forceAppLaunch) {
|
|
162
|
+
[app fb_activate];
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
|
|
@@ -263,7 +265,7 @@
|
|
|
263
265
|
|
|
264
266
|
+ (id<FBResponsePayload>)handleGetHealthCheck:(FBRouteRequest *)request
|
|
265
267
|
{
|
|
266
|
-
if (![[XCUIDevice sharedDevice] fb_healthCheckWithApplication:[
|
|
268
|
+
if (![[XCUIDevice sharedDevice] fb_healthCheckWithApplication:[FBApplication fb_activeApplication]]) {
|
|
267
269
|
return FBResponseWithUnknownErrorFormat(@"Health check failed");
|
|
268
270
|
}
|
|
269
271
|
return FBResponseWithOK();
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBAlert.h"
|
|
11
11
|
|
|
12
|
+
#import "FBApplication.h"
|
|
12
13
|
#import "FBConfiguration.h"
|
|
13
14
|
#import "FBErrorBuilder.h"
|
|
14
15
|
#import "FBLogger.h"
|
|
15
16
|
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
16
17
|
#import "FBXCodeCompatibility.h"
|
|
17
|
-
#import "XCUIApplication.h"
|
|
18
18
|
#import "XCUIApplication+FBAlert.h"
|
|
19
19
|
#import "XCUIElement+FBClassChain.h"
|
|
20
20
|
#import "XCUIElement+FBTyping.h"
|
|
@@ -263,8 +263,8 @@
|
|
|
263
263
|
if (nil == self.element) {
|
|
264
264
|
self.element = self.application.fb_alertElement;
|
|
265
265
|
if (nil == self.element) {
|
|
266
|
-
|
|
267
|
-
for (
|
|
266
|
+
FBApplication *systemApp = FBApplication.fb_systemApplication;
|
|
267
|
+
for (FBApplication *activeApp in FBApplication.fb_activeApplications) {
|
|
268
268
|
if (systemApp.processID == activeApp.processID) {
|
|
269
269
|
self.element = activeApp.fb_alertElement;
|
|
270
270
|
break;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the BSD-style license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
7
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <WebDriverAgentLib/XCUIApplication.h>
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
+
|
|
14
|
+
@interface FBApplication : XCUIApplication
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
Constructor used to get current active application
|
|
18
|
+
*/
|
|
19
|
+
+ (instancetype)fb_activeApplication;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
Constructor used to get current active application
|
|
23
|
+
|
|
24
|
+
@param bundleId The bundle identifier of an app, which should be selected as active by default
|
|
25
|
+
if it is present in the list of active applications
|
|
26
|
+
*/
|
|
27
|
+
+ (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bundleId;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
Constructor used to get the system application (e.g. Springboard on iOS)
|
|
31
|
+
*/
|
|
32
|
+
+ (instancetype)fb_systemApplication;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
Retrieves the list of all currently active applications
|
|
36
|
+
*/
|
|
37
|
+
+ (NSArray<FBApplication *> *)fb_activeApplications;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
Switch to system app (called Springboard on iOS)
|
|
41
|
+
|
|
42
|
+
@param error If there is an error, upon return contains an NSError object that describes the problem.
|
|
43
|
+
@return YES if the operation succeeds, otherwise NO.
|
|
44
|
+
*/
|
|
45
|
+
+ (BOOL)fb_switchToSystemApplicationWithError:(NSError **)error;
|
|
46
|
+
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
NS_ASSUME_NONNULL_END
|