appium-webdriveragent 4.7.0 → 4.8.0

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.
Files changed (102) hide show
  1. package/PrivateHeaders/XCTest/XCAXClient_iOS.h +2 -4
  2. package/PrivateHeaders/XCTest/XCActivityRecord.h +3 -3
  3. package/PrivateHeaders/XCTest/XCApplicationQuery.h +3 -3
  4. package/PrivateHeaders/XCTest/XCTElementSetTransformer-Protocol.h +2 -2
  5. package/PrivateHeaders/XCTest/XCTRunnerDaemonSession.h +1 -1
  6. package/PrivateHeaders/XCTest/XCTestManager_IDEInterface-Protocol.h +5 -5
  7. package/PrivateHeaders/XCTest/XCTestManager_ManagerInterface-Protocol.h +8 -8
  8. package/PrivateHeaders/XCTest/XCUIApplication.h +2 -2
  9. package/PrivateHeaders/XCTest/XCUIApplicationImpl.h +2 -2
  10. package/PrivateHeaders/XCTest/XCUIApplicationProcess.h +3 -5
  11. package/PrivateHeaders/XCTest/XCUIElement.h +3 -3
  12. package/PrivateHeaders/XCTest/XCUIElementQuery.h +4 -4
  13. package/PrivateHeaders/XCTest/XCUIRecorderNodeFinder.h +3 -3
  14. package/PrivateHeaders/XCTest/XCUIRecorderUtilities.h +3 -3
  15. package/Scripts/build.sh +3 -6
  16. package/WebDriverAgent.xcodeproj/project.pbxproj +66 -70
  17. package/WebDriverAgent.xcodeproj/project.xcworkspace/xcuserdata/elf.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  18. package/WebDriverAgent.xcodeproj/xcuserdata/elf.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +91 -0
  19. package/WebDriverAgent.xcodeproj/xcuserdata/elf.xcuserdatad/xcschemes/xcschememanagement.plist +59 -0
  20. package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.h → FBXCElementSnapshotWrapper+Helpers.h} +18 -11
  21. package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.m → FBXCElementSnapshotWrapper+Helpers.m} +57 -39
  22. package/WebDriverAgentLib/Categories/NSExpression+FBFormat.m +8 -3
  23. package/WebDriverAgentLib/Categories/XCUIApplication+FBAlert.m +8 -7
  24. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +2 -2
  25. package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +29 -28
  26. package/WebDriverAgentLib/Categories/XCUIApplicationProcess+FBQuiescence.m +5 -0
  27. package/WebDriverAgentLib/Categories/XCUICoordinate+FBFix.m +0 -1
  28. package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +8 -5
  29. package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.h +2 -2
  30. package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m +5 -4
  31. package/WebDriverAgentLib/Categories/XCUIElement+FBCaching.m +3 -2
  32. package/WebDriverAgentLib/Categories/XCUIElement+FBFind.m +22 -18
  33. package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.h +2 -3
  34. package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m +28 -26
  35. package/WebDriverAgentLib/Categories/XCUIElement+FBPickerWheel.m +2 -1
  36. package/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m +8 -4
  37. package/WebDriverAgentLib/Categories/XCUIElement+FBScrolling.m +73 -51
  38. package/WebDriverAgentLib/Categories/XCUIElement+FBTyping.m +11 -10
  39. package/WebDriverAgentLib/Categories/XCUIElement+FBUID.h +10 -5
  40. package/WebDriverAgentLib/Categories/XCUIElement+FBUID.m +15 -3
  41. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h +7 -7
  42. package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +29 -20
  43. package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.h +2 -2
  44. package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m +16 -13
  45. package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.h +2 -3
  46. package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.m +3 -3
  47. package/WebDriverAgentLib/Commands/FBElementCommands.m +15 -14
  48. package/WebDriverAgentLib/Commands/FBFindElementCommands.m +5 -6
  49. package/WebDriverAgentLib/FBAlert.m +16 -13
  50. package/WebDriverAgentLib/FBApplication.m +8 -8
  51. package/WebDriverAgentLib/Routing/FBElementUtils.h +11 -2
  52. package/WebDriverAgentLib/Routing/FBElementUtils.m +15 -12
  53. package/WebDriverAgentLib/Routing/FBResponsePayload.m +11 -10
  54. package/WebDriverAgentLib/Routing/FBSession.m +1 -1
  55. package/{PrivateHeaders/XCTest/XCAccessibilityElement.h → WebDriverAgentLib/Routing/FBXCAccessibilityElement.h} +19 -18
  56. package/WebDriverAgentLib/{Categories/XCAccessibilityElement+FBComparison.m → Routing/FBXCAccessibilityElement.m} +5 -11
  57. package/WebDriverAgentLib/Routing/FBXCDeviceEvent.h +35 -0
  58. package/WebDriverAgentLib/Routing/FBXCDeviceEvent.m +43 -0
  59. package/{PrivateHeaders/XCTest/XCElementSnapshot.h → WebDriverAgentLib/Routing/FBXCElementSnapshot.h} +25 -44
  60. package/WebDriverAgentLib/Routing/FBXCElementSnapshot.m +10 -0
  61. package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.h +30 -0
  62. package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.m +45 -0
  63. package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.h +3 -4
  64. package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.m +4 -4
  65. package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.h +2 -2
  66. package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.m +7 -8
  67. package/WebDriverAgentLib/Utilities/FBClassChainQueryParser.m +1 -2
  68. package/WebDriverAgentLib/Utilities/FBConfiguration.m +0 -1
  69. package/WebDriverAgentLib/Utilities/FBImageIOScaler.m +3 -0
  70. package/WebDriverAgentLib/Utilities/FBKeyboard.m +1 -2
  71. package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -1
  72. package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +3 -3
  73. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +10 -9
  74. package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +14 -8
  75. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.h +0 -1
  76. package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +6 -0
  77. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -10
  78. package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +0 -24
  79. package/WebDriverAgentLib/Utilities/FBXPath-Private.h +1 -1
  80. package/WebDriverAgentLib/Utilities/FBXPath.h +3 -3
  81. package/WebDriverAgentLib/Utilities/FBXPath.m +15 -13
  82. package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.h +14 -1
  83. package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.m +18 -9
  84. package/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m +9 -3
  85. package/WebDriverAgentLib/Utilities/XCUIApplicationProcessDelay.m +7 -1
  86. package/WebDriverAgentLib/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +7 -1
  87. package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
  88. package/WebDriverAgentRunner-Runner.app.zip +0 -0
  89. package/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m +26 -19
  90. package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHelperTests.m +24 -29
  91. package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHitPointTests.m +2 -2
  92. package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +5 -3
  93. package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +2 -1
  94. package/{WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.h → WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.h} +3 -14
  95. package/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m +99 -0
  96. package/WebDriverAgentTests/UnitTests/FBXPathTests.m +21 -13
  97. package/WebDriverAgentTests/UnitTests/NSPredicateFBFormatTests.m +4 -5
  98. package/package.json +1 -1
  99. package/WebDriverAgentLib/Categories/XCAccessibilityElement+FBComparison.h +0 -27
  100. package/WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.m +0 -29
  101. package/WebDriverAgentLib/Utilities/FBPredicate.h +0 -28
  102. package/WebDriverAgentLib/Utilities/FBPredicate.m +0 -29
@@ -0,0 +1,91 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Bucket
3
+ uuid = "2F0174F2-ED3F-4D11-9A17-7C590053D796"
4
+ type = "1"
5
+ version = "2.0">
6
+ <Breakpoints>
7
+ <BreakpointProxy
8
+ BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
9
+ <BreakpointContent
10
+ uuid = "471ECA8C-2C53-4C59-88DB-1C1CB3D61601"
11
+ shouldBeEnabled = "No"
12
+ ignoreCount = "0"
13
+ continueAfterRunningActions = "No"
14
+ breakpointStackSelectionBehavior = "1"
15
+ scope = "1"
16
+ stopOnStyle = "0">
17
+ </BreakpointContent>
18
+ </BreakpointProxy>
19
+ <BreakpointProxy
20
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
21
+ <BreakpointContent
22
+ uuid = "C2E06865-6A52-4686-9771-279AF13ABF8A"
23
+ shouldBeEnabled = "Yes"
24
+ ignoreCount = "0"
25
+ continueAfterRunningActions = "No"
26
+ filePath = "WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m"
27
+ timestampString = "0"
28
+ startingColumnNumber = "9223372036854775807"
29
+ endingColumnNumber = "9223372036854775807"
30
+ startingLineNumber = "264"
31
+ endingLineNumber = "264">
32
+ </BreakpointContent>
33
+ </BreakpointProxy>
34
+ <BreakpointProxy
35
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
36
+ <BreakpointContent
37
+ uuid = "54216FE6-E240-47F1-88D3-D450CF0AF44E"
38
+ shouldBeEnabled = "Yes"
39
+ ignoreCount = "0"
40
+ continueAfterRunningActions = "No"
41
+ filePath = "WebDriverAgentLib/Categories/XCUIElement+FBResolve.m"
42
+ startingColumnNumber = "9223372036854775807"
43
+ endingColumnNumber = "9223372036854775807"
44
+ startingLineNumber = "37"
45
+ endingLineNumber = "37"
46
+ landmarkName = "-fb_stableInstance"
47
+ landmarkType = "7">
48
+ <Locations>
49
+ <Location
50
+ uuid = "54216FE6-E240-47F1-88D3-D450CF0AF44E - b09f4ce1ce926e6"
51
+ shouldBeEnabled = "Yes"
52
+ ignoreCount = "0"
53
+ continueAfterRunningActions = "No"
54
+ symbolName = "-[XCUIElement(FBResolve) fb_stableInstance]"
55
+ moduleName = "WebDriverAgentLib"
56
+ usesParentBreakpointCondition = "Yes"
57
+ urlString = "file:///Users/elf/code/WebDriverAgent/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m"
58
+ startingColumnNumber = "9223372036854775807"
59
+ endingColumnNumber = "9223372036854775807"
60
+ startingLineNumber = "37"
61
+ endingLineNumber = "37"
62
+ offsetFromSymbolStart = "19">
63
+ </Location>
64
+ <Location
65
+ shouldBeEnabled = "Yes"
66
+ ignoreCount = "0"
67
+ continueAfterRunningActions = "No"
68
+ usesParentBreakpointCondition = "Yes"
69
+ offsetFromSymbolStart = "0">
70
+ </Location>
71
+ </Locations>
72
+ </BreakpointContent>
73
+ </BreakpointProxy>
74
+ <BreakpointProxy
75
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
76
+ <BreakpointContent
77
+ uuid = "D3009B57-42BC-4905-99BC-70232544FAFB"
78
+ shouldBeEnabled = "Yes"
79
+ ignoreCount = "0"
80
+ continueAfterRunningActions = "No"
81
+ filePath = "WebDriverAgentTests/IntegrationTests/FBAlertTests.m"
82
+ startingColumnNumber = "5"
83
+ endingColumnNumber = "64"
84
+ startingLineNumber = "32"
85
+ endingLineNumber = "32"
86
+ landmarkName = "-setUp"
87
+ landmarkType = "7">
88
+ </BreakpointContent>
89
+ </BreakpointProxy>
90
+ </Breakpoints>
91
+ </Bucket>
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>IntegrationApp.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ <key>IntegrationTests_1.xcscheme_^#shared#^_</key>
13
+ <dict>
14
+ <key>orderHint</key>
15
+ <integer>1</integer>
16
+ </dict>
17
+ <key>IntegrationTests_2.xcscheme_^#shared#^_</key>
18
+ <dict>
19
+ <key>orderHint</key>
20
+ <integer>2</integer>
21
+ </dict>
22
+ <key>IntegrationTests_3.xcscheme_^#shared#^_</key>
23
+ <dict>
24
+ <key>orderHint</key>
25
+ <integer>3</integer>
26
+ </dict>
27
+ <key>WebDriverAgentLib copy.xcscheme_^#shared#^_</key>
28
+ <dict>
29
+ <key>orderHint</key>
30
+ <integer>9</integer>
31
+ </dict>
32
+ <key>WebDriverAgentLib.xcscheme_^#shared#^_</key>
33
+ <dict>
34
+ <key>orderHint</key>
35
+ <integer>4</integer>
36
+ </dict>
37
+ <key>WebDriverAgentLib_tvOS.xcscheme_^#shared#^_</key>
38
+ <dict>
39
+ <key>orderHint</key>
40
+ <integer>5</integer>
41
+ </dict>
42
+ <key>WebDriverAgentRunner-nodebug.xcscheme_^#shared#^_</key>
43
+ <dict>
44
+ <key>orderHint</key>
45
+ <integer>7</integer>
46
+ </dict>
47
+ <key>WebDriverAgentRunner.xcscheme_^#shared#^_</key>
48
+ <dict>
49
+ <key>orderHint</key>
50
+ <integer>6</integer>
51
+ </dict>
52
+ <key>WebDriverAgentRunner_tvOS.xcscheme_^#shared#^_</key>
53
+ <dict>
54
+ <key>orderHint</key>
55
+ <integer>8</integer>
56
+ </dict>
57
+ </dict>
58
+ </dict>
59
+ </plist>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) 2018-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,11 +7,11 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  */
9
9
 
10
- #import <WebDriverAgentLib/XCElementSnapshot.h>
10
+ #import "FBXCElementSnapshotWrapper.h"
11
11
 
12
12
  NS_ASSUME_NONNULL_BEGIN
13
13
 
14
- @interface XCElementSnapshot (FBHelpers)
14
+ @interface FBXCElementSnapshotWrapper (Helpers)
15
15
 
16
16
  /**
17
17
  Returns an array of descendants matching given type
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
19
19
  @param type requested descendant type
20
20
  @return an array of descendants matching given type
21
21
  */
22
- - (NSArray<XCElementSnapshot *> *)fb_descendantsMatchingType:(XCUIElementType)type;
22
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_descendantsMatchingType:(XCUIElementType)type;
23
23
 
24
24
  /**
25
25
  Returns first (going up element tree) parent that matches given type. If non found returns nil.
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
27
27
  @param type requested parent type
28
28
  @return parent element matching given type
29
29
  */
30
- - (nullable XCElementSnapshot *)fb_parentMatchingType:(XCUIElementType)type;
30
+ - (nullable id<FBXCElementSnapshot>)fb_parentMatchingType:(XCUIElementType)type;
31
31
 
32
32
  /**
33
33
  Returns first (going up element tree) parent that matches one of given types. If non found returns nil.
@@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
35
35
  @param types possible parent types
36
36
  @return parent element matching one of given types
37
37
  */
38
- - (nullable XCElementSnapshot *)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types;
38
+ - (nullable id<FBXCElementSnapshot>)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types;
39
39
 
40
40
  /**
41
41
  Returns first (going up element tree) visible parent that matches one of given types and has more than one child. If non found returns nil.
@@ -44,14 +44,14 @@ NS_ASSUME_NONNULL_BEGIN
44
44
  @param filter will filter results even further after matching one of given types
45
45
  @return parent element matching one of given types and satisfying filter condition
46
46
  */
47
- - (nullable XCElementSnapshot *)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types filter:(BOOL(^)(XCElementSnapshot *snapshot))filter;
47
+ - (nullable id<FBXCElementSnapshot>)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types filter:(BOOL(^)(id<FBXCElementSnapshot> snapshot))filter;
48
48
 
49
49
  /**
50
50
  Retrieves the list of all element ancestors in the snapshot hierarchy.
51
51
 
52
52
  @return the list of element ancestors or an empty list if the snapshot has no parent.
53
53
  */
54
- - (NSArray<XCElementSnapshot *> *)fb_ancestors;
54
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_ancestors;
55
55
 
56
56
  /**
57
57
  Returns value for given accessibility property identifier.
@@ -68,21 +68,21 @@ NS_ASSUME_NONNULL_BEGIN
68
68
  @param snapshot element's snapshot to compare against
69
69
  @return YES, if they match otherwise NO
70
70
  */
71
- - (BOOL)fb_framelessFuzzyMatchesElement:(XCElementSnapshot *)snapshot;
71
+ - (BOOL)fb_framelessFuzzyMatchesElement:(id<FBXCElementSnapshot>)snapshot;
72
72
 
73
73
  /**
74
74
  Returns an array of descendants cell snapshots
75
75
 
76
76
  @return an array of descendants cell snapshots
77
77
  */
78
- - (NSArray<XCElementSnapshot *> *)fb_descendantsCellSnapshots;
78
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_descendantsCellSnapshots;
79
79
 
80
80
  /**
81
81
  Returns itself if it is either XCUIElementTypeIcon or XCUIElementTypeCell. Otherwise, returns first (going up element tree) parent that matches cell (XCUIElementTypeCell or XCUIElementTypeIcon). If non found returns nil.
82
82
 
83
83
  @return parent element matching either XCUIElementTypeIcon or XCUIElementTypeCell.
84
84
  */
85
- - (nullable XCElementSnapshot *)fb_parentCellSnapshot;
85
+ - (nullable id<FBXCElementSnapshot>)fb_parentCellSnapshot;
86
86
 
87
87
  /**! Human-readable snapshot description */
88
88
  - (NSString *)fb_description;
@@ -94,6 +94,13 @@ NS_ASSUME_NONNULL_BEGIN
94
94
  */
95
95
  - (CGRect)fb_visibleFrameWithFallback;
96
96
 
97
+ /**
98
+ Wrapper for Apple's hitpoint, thats resolves few known issues
99
+
100
+ @return Element's hitpoint if exists nil otherwise
101
+ */
102
+ - (nullable NSValue *)fb_hitPoint;
103
+
97
104
  @end
98
105
 
99
106
  NS_ASSUME_NONNULL_END
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) 2018-present, Facebook, Inc.
3
3
  * All rights reserved.
4
4
  *
5
5
  * This source code is licensed under the BSD-style license found in the
@@ -7,20 +7,23 @@
7
7
  * of patent rights can be found in the PATENTS file in the same directory.
8
8
  */
9
9
 
10
- #import "XCElementSnapshot+FBHelpers.h"
10
+ #import "FBXCElementSnapshotWrapper+Helpers.h"
11
11
 
12
12
  #import "FBFindElementCommands.h"
13
13
  #import "FBRunLoopSpinner.h"
14
14
  #import "FBLogger.h"
15
+ #import "FBXCElementSnapshot.h"
15
16
  #import "FBXCAXClientProxy.h"
16
17
  #import "XCTestDriver.h"
17
18
  #import "XCTestPrivateSymbols.h"
18
19
  #import "XCUIElement.h"
19
20
  #import "XCUIElement+FBWebDriverAttributes.h"
21
+ #import "XCUIHitPointResult.h"
20
22
 
21
- inline static BOOL isSnapshotTypeAmongstGivenTypes(XCElementSnapshot* snapshot, NSArray<NSNumber *> *types);
23
+ inline static BOOL isSnapshotTypeAmongstGivenTypes(id<FBXCElementSnapshot> snapshot,
24
+ NSArray<NSNumber *> *types);
22
25
 
23
- @implementation XCElementSnapshot (FBHelpers)
26
+ @implementation FBXCElementSnapshotWrapper (Helpers)
24
27
 
25
28
  - (NSString *)fb_description
26
29
  {
@@ -31,29 +34,30 @@ inline static BOOL isSnapshotTypeAmongstGivenTypes(XCElementSnapshot* snapshot,
31
34
  return result;
32
35
  }
33
36
 
34
- - (NSArray<XCElementSnapshot *> *)fb_descendantsMatchingType:(XCUIElementType)type
37
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_descendantsMatchingType:(XCUIElementType)type
35
38
  {
36
- return [self descendantsByFilteringWithBlock:^BOOL(XCElementSnapshot *snapshot) {
39
+ return [self descendantsByFilteringWithBlock:^BOOL(id<FBXCElementSnapshot> snapshot) {
37
40
  return snapshot.elementType == type;
38
41
  }];
39
42
  }
40
43
 
41
- - (XCElementSnapshot *)fb_parentMatchingType:(XCUIElementType)type
44
+ - (id<FBXCElementSnapshot>)fb_parentMatchingType:(XCUIElementType)type
42
45
  {
43
46
  NSArray *acceptedParents = @[@(type)];
44
47
  return [self fb_parentMatchingOneOfTypes:acceptedParents];
45
48
  }
46
49
 
47
- - (XCElementSnapshot *)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types
50
+ - (id<FBXCElementSnapshot>)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types
48
51
  {
49
- return [self fb_parentMatchingOneOfTypes:types filter:^(XCElementSnapshot *snapshot) {
52
+ return [self fb_parentMatchingOneOfTypes:types filter:^(id<FBXCElementSnapshot> snapshot) {
50
53
  return YES;
51
54
  }];
52
55
  }
53
56
 
54
- - (XCElementSnapshot *)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types filter:(BOOL(^)(XCElementSnapshot *snapshot))filter
57
+ - (id<FBXCElementSnapshot>)fb_parentMatchingOneOfTypes:(NSArray<NSNumber *> *)types
58
+ filter:(BOOL(^)(id<FBXCElementSnapshot> snapshot))filter
55
59
  {
56
- XCElementSnapshot *snapshot = self.parent;
60
+ id<FBXCElementSnapshot> snapshot = self.parent;
57
61
  while (snapshot && !(isSnapshotTypeAmongstGivenTypes(snapshot, types) && filter(snapshot))) {
58
62
  snapshot = snapshot.parent;
59
63
  }
@@ -73,12 +77,15 @@ inline static BOOL areValuesEqualOrBlank(id value1, id value2);
73
77
 
74
78
  inline static BOOL isNilOrEmpty(id value);
75
79
 
76
- - (BOOL)fb_framelessFuzzyMatchesElement:(XCElementSnapshot *)snapshot
80
+ - (BOOL)fb_framelessFuzzyMatchesElement:(id<FBXCElementSnapshot>)snapshot
77
81
  {
78
82
  // Pure payload-based comparison sometimes yield false negatives, therefore relying on it only if all of the identifying properties are blank
79
- if (isNilOrEmpty(self.identifier) && isNilOrEmpty(self.title) && isNilOrEmpty(self.label) &&
80
- isNilOrEmpty(self.value) && isNilOrEmpty(self.placeholderValue)) {
81
- return [self.wdUID isEqualToString:(snapshot.wdUID ?: @"")];
83
+ if (isNilOrEmpty(self.identifier)
84
+ && isNilOrEmpty(self.title)
85
+ && isNilOrEmpty(self.label)
86
+ && isNilOrEmpty(self.value)
87
+ && isNilOrEmpty(self.placeholderValue)) {
88
+ return [self.wdUID isEqualToString:([FBXCElementSnapshotWrapper ensureWrapped:snapshot].wdUID ?: @"")];
82
89
  }
83
90
 
84
91
  // Sometimes value and placeholderValue of a correct match from different snapshots are not the same (one is nil and one is a blank string)
@@ -91,27 +98,27 @@ inline static BOOL isNilOrEmpty(id value);
91
98
  areValuesEqualOrBlank(self.placeholderValue, snapshot.placeholderValue);
92
99
  }
93
100
 
94
- - (NSArray<XCElementSnapshot *> *)fb_descendantsCellSnapshots
101
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_descendantsCellSnapshots
95
102
  {
96
- NSArray<XCElementSnapshot *> *cellSnapshots = [self fb_descendantsMatchingType:XCUIElementTypeCell];
97
-
103
+ NSArray<id<FBXCElementSnapshot>> *cellSnapshots = [self fb_descendantsMatchingType:XCUIElementTypeCell];
104
+
98
105
  if (cellSnapshots.count == 0) {
99
- // For the home screen, cells are actually of type XCUIElementTypeIcon
100
- cellSnapshots = [self fb_descendantsMatchingType:XCUIElementTypeIcon];
106
+ // For the home screen, cells are actually of type XCUIElementTypeIcon
107
+ cellSnapshots = [self fb_descendantsMatchingType:XCUIElementTypeIcon];
101
108
  }
102
-
109
+
103
110
  if (cellSnapshots.count == 0) {
104
- // In some cases XCTest will not report Cell Views. In that case grab all descendants and try to figure out scroll directon from them.
105
- cellSnapshots = self._allDescendants;
111
+ // In some cases XCTest will not report Cell Views. In that case grab all descendants and try to figure out scroll directon from them.
112
+ cellSnapshots = self._allDescendants;
106
113
  }
107
114
 
108
- return cellSnapshots;
115
+ return cellSnapshots;
109
116
  }
110
117
 
111
- - (NSArray<XCElementSnapshot *> *)fb_ancestors
118
+ - (NSArray<id<FBXCElementSnapshot>> *)fb_ancestors
112
119
  {
113
- NSMutableArray<XCElementSnapshot *> *ancestors = [NSMutableArray array];
114
- XCElementSnapshot *parent = self.parent;
120
+ NSMutableArray<id<FBXCElementSnapshot>> *ancestors = [NSMutableArray array];
121
+ id<FBXCElementSnapshot> parent = self.parent;
115
122
  while (parent) {
116
123
  [ancestors addObject:parent];
117
124
  parent = parent.parent;
@@ -119,18 +126,18 @@ inline static BOOL isNilOrEmpty(id value);
119
126
  return ancestors.copy;
120
127
  }
121
128
 
122
- - (XCElementSnapshot *)fb_parentCellSnapshot
129
+ - (id<FBXCElementSnapshot>)fb_parentCellSnapshot
123
130
  {
124
- XCElementSnapshot *targetCellSnapshot = self;
125
- // XCUIElementTypeIcon is the cell type for homescreen icons
126
- NSArray<NSNumber *> *acceptableElementTypes = @[
127
- @(XCUIElementTypeCell),
128
- @(XCUIElementTypeIcon),
129
- ];
130
- if (self.elementType != XCUIElementTypeCell && self.elementType != XCUIElementTypeIcon) {
131
- targetCellSnapshot = [self fb_parentMatchingOneOfTypes:acceptableElementTypes];
132
- }
133
- return targetCellSnapshot;
131
+ id<FBXCElementSnapshot> targetCellSnapshot = self.snapshot;
132
+ // XCUIElementTypeIcon is the cell type for homescreen icons
133
+ NSArray<NSNumber *> *acceptableElementTypes = @[
134
+ @(XCUIElementTypeCell),
135
+ @(XCUIElementTypeIcon),
136
+ ];
137
+ if (self.elementType != XCUIElementTypeCell && self.elementType != XCUIElementTypeIcon) {
138
+ targetCellSnapshot = [self fb_parentMatchingOneOfTypes:acceptableElementTypes];
139
+ }
140
+ return targetCellSnapshot;
134
141
  }
135
142
 
136
143
  - (CGRect)fb_visibleFrameWithFallback
@@ -156,9 +163,20 @@ inline static BOOL isNilOrEmpty(id value);
156
163
  return thisVisibleFrame;
157
164
  }
158
165
 
166
+ - (NSValue *)fb_hitPoint
167
+ {
168
+ NSError *error;
169
+ XCUIHitPointResult *result = [self hitPoint:&error];
170
+ if (nil != error) {
171
+ [FBLogger logFmt:@"Failed to fetch hit point for %@ - %@", self.fb_description, error.localizedDescription];
172
+ return nil;
173
+ }
174
+ return [NSValue valueWithCGPoint:result.hitPoint];
175
+ }
176
+
159
177
  @end
160
178
 
161
- inline static BOOL isSnapshotTypeAmongstGivenTypes(XCElementSnapshot* snapshot, NSArray<NSNumber *> *types)
179
+ inline static BOOL isSnapshotTypeAmongstGivenTypes(id<FBXCElementSnapshot> snapshot, NSArray<NSNumber *> *types)
162
180
  {
163
181
  for (NSUInteger i = 0; i < types.count; i++) {
164
182
  if([@(snapshot.elementType) isEqual: types[i]] || [types[i] isEqual: @(XCUIElementTypeAny)]){
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  #import "NSExpression+FBFormat.h"
11
+
11
12
  #import "FBElementUtils.h"
12
13
 
13
14
  @implementation NSExpression (FBFormat)
@@ -17,14 +18,18 @@
17
18
  if ([input expressionType] != NSKeyPathExpressionType) {
18
19
  return input;
19
20
  }
21
+
20
22
  NSString *propName = [input keyPath];
21
23
  NSUInteger dotPos = [propName rangeOfString:@"."].location;
22
- if (NSNotFound != dotPos) {
24
+ NSString *wdPropName;
25
+ if (NSNotFound == dotPos) {
26
+ wdPropName = [FBElementUtils wdAttributeNameForAttributeName:propName];
27
+ } else {
23
28
  NSString *actualPropName = [propName substringToIndex:dotPos];
24
29
  NSString *suffix = [propName substringFromIndex:(dotPos + 1)];
25
- return [NSExpression expressionForKeyPath:[NSString stringWithFormat:@"%@.%@", [FBElementUtils wdAttributeNameForAttributeName:actualPropName], suffix]];
30
+ wdPropName = [NSString stringWithFormat:@"%@.%@", [FBElementUtils wdAttributeNameForAttributeName:actualPropName], suffix];
26
31
  }
27
- return [NSExpression expressionForKeyPath:[FBElementUtils wdAttributeNameForAttributeName:propName]];
32
+ return [NSExpression expressionForKeyPath:wdPropName];
28
33
  }
29
34
 
30
35
  @end
@@ -10,6 +10,7 @@
10
10
  #import "XCUIApplication+FBAlert.h"
11
11
 
12
12
  #import "FBMacros.h"
13
+ #import "FBXCElementSnapshotWrapper+Helpers.h"
13
14
  #import "FBXCodeCompatibility.h"
14
15
  #import "XCUIElement+FBUtilities.h"
15
16
 
@@ -21,10 +22,10 @@ NSString *const FB_SAFARI_APP_NAME = @"Safari";
21
22
  @implementation XCUIApplication (FBAlert)
22
23
 
23
24
  - (nullable XCUIElement *)fb_alertElementFromSafariWithScrollView:(XCUIElement *)scrollView
24
- viewSnapshot:(XCElementSnapshot *)viewSnapshot
25
+ viewSnapshot:(id<FBXCElementSnapshot>)viewSnapshot
25
26
  {
26
27
  CGRect appFrame = viewSnapshot.frame;
27
- NSPredicate *dstViewMatchPredicate = [NSPredicate predicateWithBlock:^BOOL(XCElementSnapshot *snapshot, NSDictionary *bindings) {
28
+ NSPredicate *dstViewMatchPredicate = [NSPredicate predicateWithBlock:^BOOL(id<FBXCElementSnapshot> snapshot, NSDictionary *bindings) {
28
29
  CGRect curFrame = snapshot.frame;
29
30
  if (!CGRectEqualToRect(appFrame, curFrame)
30
31
  && curFrame.origin.x > 0 && curFrame.size.width < appFrame.size.width) {
@@ -62,8 +63,8 @@ NSString *const FB_SAFARI_APP_NAME = @"Safari";
62
63
  // and conatins at least one text view
63
64
  __block NSUInteger buttonsCount = 0;
64
65
  __block NSUInteger textViewsCount = 0;
65
- XCElementSnapshot *snapshot = candidate.fb_cachedSnapshot ?: candidate.fb_takeSnapshot;
66
- [snapshot enumerateDescendantsUsingBlock:^(XCElementSnapshot *descendant) {
66
+ id<FBXCElementSnapshot> snapshot = candidate.fb_cachedSnapshot ?: candidate.fb_takeSnapshot;
67
+ [snapshot enumerateDescendantsUsingBlock:^(id<FBXCElementSnapshot> descendant) {
67
68
  XCUIElementType curType = descendant.elementType;
68
69
  if (curType == XCUIElementTypeButton) {
69
70
  buttonsCount++;
@@ -83,7 +84,7 @@ NSString *const FB_SAFARI_APP_NAME = @"Safari";
83
84
  if (nil == alert) {
84
85
  return nil;
85
86
  }
86
- XCElementSnapshot *alertSnapshot = alert.fb_cachedSnapshot ?: alert.fb_takeSnapshot;
87
+ id<FBXCElementSnapshot> alertSnapshot = alert.fb_cachedSnapshot ?: alert.fb_takeSnapshot;
87
88
 
88
89
  if (alertSnapshot.elementType == XCUIElementTypeAlert) {
89
90
  return alert;
@@ -96,7 +97,7 @@ NSString *const FB_SAFARI_APP_NAME = @"Safari";
96
97
 
97
98
  // In case of iPad we want to check if sheet isn't contained by popover.
98
99
  // In that case we ignore it.
99
- XCElementSnapshot *ancestor = alertSnapshot.parent;
100
+ id<FBXCElementSnapshot> ancestor = alertSnapshot.parent;
100
101
  while (nil != ancestor) {
101
102
  if (nil != ancestor.identifier && [ancestor.identifier isEqualToString:@"PopoverDismissRegion"]) {
102
103
  return nil;
@@ -107,7 +108,7 @@ NSString *const FB_SAFARI_APP_NAME = @"Safari";
107
108
  }
108
109
 
109
110
  if (alertSnapshot.elementType == XCUIElementTypeScrollView) {
110
- XCElementSnapshot *app = [alertSnapshot fb_parentMatchingType:XCUIElementTypeApplication];
111
+ id<FBXCElementSnapshot> app = [[FBXCElementSnapshotWrapper ensureWrapped:alertSnapshot] fb_parentMatchingType:XCUIElementTypeApplication];
111
112
  if (nil != app && [app.label isEqualToString:FB_SAFARI_APP_NAME]) {
112
113
  // Check alert presence in Safari web view
113
114
  return [self fb_alertElementFromSafariWithScrollView:alert viewSnapshot:alertSnapshot];
@@ -10,7 +10,7 @@
10
10
  #import <XCTest/XCTest.h>
11
11
 
12
12
  @class XCElementSnapshot;
13
- @class XCAccessibilityElement;
13
+ @protocol FBXCAccessibilityElement;
14
14
  @class FBXMLGenerationOptions;
15
15
 
16
16
  NS_ASSUME_NONNULL_BEGIN
@@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
83
83
  @param axElements the list of accessibility elements
84
84
  @returns The list of dictionaries. Each dictionary contains `bundleId` and `pid` items
85
85
  */
86
- + (NSArray<NSDictionary<NSString *, id> *> *)fb_appsInfoWithAxElements:(NSArray<XCAccessibilityElement *> *)axElements;
86
+ + (NSArray<NSDictionary<NSString *, id> *> *)fb_appsInfoWithAxElements:(NSArray<id<FBXCAccessibilityElement>> *)axElements;
87
87
 
88
88
  /**
89
89
  Retrieves the information about the currently active apps