appium-webdriveragent 4.7.0 → 4.8.2
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/PrivateHeaders/XCTest/XCAXClient_iOS.h +2 -4
- package/PrivateHeaders/XCTest/XCActivityRecord.h +3 -3
- package/PrivateHeaders/XCTest/XCApplicationQuery.h +3 -3
- package/PrivateHeaders/XCTest/XCTElementSetTransformer-Protocol.h +2 -2
- package/PrivateHeaders/XCTest/XCTRunnerDaemonSession.h +1 -1
- package/PrivateHeaders/XCTest/XCTestManager_IDEInterface-Protocol.h +5 -5
- package/PrivateHeaders/XCTest/XCTestManager_ManagerInterface-Protocol.h +8 -8
- package/PrivateHeaders/XCTest/XCUIApplication.h +2 -2
- package/PrivateHeaders/XCTest/XCUIApplicationImpl.h +2 -2
- package/PrivateHeaders/XCTest/XCUIApplicationProcess.h +3 -5
- package/PrivateHeaders/XCTest/XCUIElement.h +3 -3
- package/PrivateHeaders/XCTest/XCUIElementQuery.h +4 -4
- package/PrivateHeaders/XCTest/XCUIRecorderNodeFinder.h +3 -3
- package/PrivateHeaders/XCTest/XCUIRecorderUtilities.h +3 -3
- package/Scripts/build.sh +3 -6
- package/WebDriverAgent.xcodeproj/project.pbxproj +66 -70
- package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.h → FBXCElementSnapshotWrapper+Helpers.h} +18 -11
- package/WebDriverAgentLib/Categories/{XCElementSnapshot+FBHelpers.m → FBXCElementSnapshotWrapper+Helpers.m} +57 -39
- package/WebDriverAgentLib/Categories/NSExpression+FBFormat.m +8 -3
- package/WebDriverAgentLib/Categories/XCUIApplication+FBAlert.m +8 -7
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.h +2 -2
- package/WebDriverAgentLib/Categories/XCUIApplication+FBHelpers.m +29 -28
- package/WebDriverAgentLib/Categories/XCUIApplicationProcess+FBQuiescence.m +5 -0
- package/WebDriverAgentLib/Categories/XCUICoordinate+FBFix.m +0 -1
- package/WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m +8 -5
- package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.h +2 -2
- package/WebDriverAgentLib/Categories/XCUIElement+FBAccessibility.m +5 -4
- package/WebDriverAgentLib/Categories/XCUIElement+FBCaching.m +3 -2
- package/WebDriverAgentLib/Categories/XCUIElement+FBFind.m +22 -18
- package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.h +2 -3
- package/WebDriverAgentLib/Categories/XCUIElement+FBIsVisible.m +28 -26
- package/WebDriverAgentLib/Categories/XCUIElement+FBPickerWheel.m +2 -1
- package/WebDriverAgentLib/Categories/XCUIElement+FBResolve.m +8 -4
- package/WebDriverAgentLib/Categories/XCUIElement+FBScrolling.m +73 -51
- package/WebDriverAgentLib/Categories/XCUIElement+FBTyping.m +11 -10
- package/WebDriverAgentLib/Categories/XCUIElement+FBUID.h +10 -5
- package/WebDriverAgentLib/Categories/XCUIElement+FBUID.m +15 -3
- package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h +7 -7
- package/WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m +29 -20
- package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.h +2 -2
- package/WebDriverAgentLib/Categories/XCUIElement+FBWebDriverAttributes.m +17 -14
- package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.h +2 -3
- package/WebDriverAgentLib/Categories/XCUIElementQuery+FBHelpers.m +3 -3
- package/WebDriverAgentLib/Commands/FBElementCommands.m +17 -15
- package/WebDriverAgentLib/Commands/FBFindElementCommands.m +5 -6
- package/WebDriverAgentLib/FBAlert.m +16 -13
- package/WebDriverAgentLib/FBApplication.m +8 -8
- package/WebDriverAgentLib/Routing/FBElementUtils.h +11 -2
- package/WebDriverAgentLib/Routing/FBElementUtils.m +15 -12
- package/WebDriverAgentLib/Routing/FBResponsePayload.m +11 -10
- package/WebDriverAgentLib/Routing/FBSession.m +1 -1
- package/{PrivateHeaders/XCTest/XCAccessibilityElement.h → WebDriverAgentLib/Routing/FBXCAccessibilityElement.h} +19 -18
- package/WebDriverAgentLib/{Categories/XCAccessibilityElement+FBComparison.m → Routing/FBXCAccessibilityElement.m} +5 -11
- package/WebDriverAgentLib/Routing/FBXCDeviceEvent.h +35 -0
- package/WebDriverAgentLib/Routing/FBXCDeviceEvent.m +43 -0
- package/{PrivateHeaders/XCTest/XCElementSnapshot.h → WebDriverAgentLib/Routing/FBXCElementSnapshot.h} +25 -44
- package/WebDriverAgentLib/Routing/FBXCElementSnapshot.m +10 -0
- package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.h +30 -0
- package/WebDriverAgentLib/Routing/FBXCElementSnapshotWrapper.m +45 -0
- package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.h +3 -4
- package/WebDriverAgentLib/Utilities/FBActiveAppDetectionPoint.m +4 -4
- package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.h +2 -2
- package/WebDriverAgentLib/Utilities/FBBaseActionsSynthesizer.m +7 -8
- package/WebDriverAgentLib/Utilities/FBClassChainQueryParser.m +1 -2
- package/WebDriverAgentLib/Utilities/FBConfiguration.m +0 -1
- package/WebDriverAgentLib/Utilities/FBImageIOScaler.m +3 -0
- package/WebDriverAgentLib/Utilities/FBKeyboard.m +1 -2
- package/WebDriverAgentLib/Utilities/FBPasteboard.m +91 -3
- package/WebDriverAgentLib/Utilities/FBTVNavigationTracker.m +1 -1
- package/WebDriverAgentLib/Utilities/FBW3CActionsSynthesizer.m +3 -3
- package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.h +10 -9
- package/WebDriverAgentLib/Utilities/FBXCAXClientProxy.m +14 -8
- package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.h +0 -1
- package/WebDriverAgentLib/Utilities/FBXCTestDaemonsProxy.m +6 -0
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.h +0 -10
- package/WebDriverAgentLib/Utilities/FBXCodeCompatibility.m +0 -24
- package/WebDriverAgentLib/Utilities/FBXPath-Private.h +1 -1
- package/WebDriverAgentLib/Utilities/FBXPath.h +3 -3
- package/WebDriverAgentLib/Utilities/FBXPath.m +15 -13
- package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.h +14 -1
- package/WebDriverAgentLib/Utilities/NSPredicate+FBFormat.m +18 -9
- package/WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m +9 -3
- package/WebDriverAgentLib/Utilities/XCUIApplicationProcessDelay.m +7 -1
- package/WebDriverAgentLib/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +7 -1
- package/WebDriverAgentLib/WebDriverAgentLib.h +0 -1
- package/WebDriverAgentRunner-Runner.app.zip +0 -0
- package/WebDriverAgentTests/IntegrationTests/FBPasteboardTests.m +1 -5
- package/WebDriverAgentTests/IntegrationTests/FBXPathIntegrationTests.m +26 -19
- package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHelperTests.m +24 -29
- package/WebDriverAgentTests/IntegrationTests/XCElementSnapshotHitPointTests.m +2 -2
- package/WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m +5 -3
- package/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m +2 -1
- package/{WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.h → WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.h} +3 -14
- package/WebDriverAgentTests/UnitTests/Doubles/XCElementSnapshotDouble.m +99 -0
- package/WebDriverAgentTests/UnitTests/FBXPathTests.m +21 -13
- package/WebDriverAgentTests/UnitTests/NSPredicateFBFormatTests.m +4 -5
- package/package.json +1 -1
- package/WebDriverAgentLib/Categories/XCAccessibilityElement+FBComparison.h +0 -27
- package/WebDriverAgentLib/Categories/XCElementSnapshot+FBHitPoint.m +0 -29
- package/WebDriverAgentLib/Utilities/FBPredicate.h +0 -28
- package/WebDriverAgentLib/Utilities/FBPredicate.m +0 -29
|
@@ -9,23 +9,20 @@
|
|
|
9
9
|
|
|
10
10
|
#import "NSPredicate+FBFormat.h"
|
|
11
11
|
|
|
12
|
-
#import "FBPredicate.h"
|
|
13
12
|
#import "NSExpression+FBFormat.h"
|
|
13
|
+
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
14
14
|
|
|
15
15
|
@implementation NSPredicate (FBFormat)
|
|
16
16
|
|
|
17
|
-
+ (instancetype)fb_predicateWithPredicate:(NSPredicate *)original
|
|
17
|
+
+ (instancetype)fb_predicateWithPredicate:(NSPredicate *)original
|
|
18
|
+
comparisonModifier:(NSPredicate *(^)(NSComparisonPredicate *))comparisonModifier
|
|
18
19
|
{
|
|
19
20
|
if ([original isKindOfClass:NSCompoundPredicate.class]) {
|
|
20
21
|
NSCompoundPredicate *compPred = (NSCompoundPredicate *)original;
|
|
21
22
|
NSMutableArray *predicates = [NSMutableArray array];
|
|
22
23
|
for (NSPredicate *predicate in [compPred subpredicates]) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[predicates addObject:predicate];
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
NSPredicate *newPredicate = [self.class fb_predicateWithPredicate:predicate comparisonModifier:comparisonModifier];
|
|
24
|
+
NSPredicate *newPredicate = [self.class fb_predicateWithPredicate:predicate
|
|
25
|
+
comparisonModifier:comparisonModifier];
|
|
29
26
|
if (nil != newPredicate) {
|
|
30
27
|
[predicates addObject:newPredicate];
|
|
31
28
|
}
|
|
@@ -41,7 +38,8 @@
|
|
|
41
38
|
|
|
42
39
|
+ (instancetype)fb_formatSearchPredicate:(NSPredicate *)input
|
|
43
40
|
{
|
|
44
|
-
return [self.class fb_predicateWithPredicate:input
|
|
41
|
+
return [self.class fb_predicateWithPredicate:input
|
|
42
|
+
comparisonModifier:^NSPredicate *(NSComparisonPredicate *cp) {
|
|
45
43
|
NSExpression *left = [NSExpression fb_wdExpressionWithExpression:[cp leftExpression]];
|
|
46
44
|
NSExpression *right = [NSExpression fb_wdExpressionWithExpression:[cp rightExpression]];
|
|
47
45
|
return [NSComparisonPredicate predicateWithLeftExpression:left
|
|
@@ -52,4 +50,15 @@
|
|
|
52
50
|
}];
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
+ (instancetype)fb_snapshotBlockPredicateWithPredicate:(NSPredicate *)input
|
|
54
|
+
{
|
|
55
|
+
NSPredicate *wdPredicate = [self.class fb_formatSearchPredicate:input];
|
|
56
|
+
return [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject,
|
|
57
|
+
NSDictionary<NSString *,id> * _Nullable bindings) {
|
|
58
|
+
FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:evaluatedObject];
|
|
59
|
+
return [wdPredicate evaluateWithObject:wrappedSnapshot];
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
55
64
|
@end
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|
#import "FBRuntimeUtils.h"
|
|
15
15
|
#import "FBXCodeCompatibility.h"
|
|
16
|
-
#import "XCElementSnapshot.h"
|
|
17
16
|
|
|
18
17
|
NSNumber *FB_XCAXAIsVisibleAttribute;
|
|
19
18
|
NSString *FB_XCAXAIsVisibleAttributeName = @"XC_kAXXCAttributeIsVisible";
|
|
@@ -56,8 +55,15 @@ void *FBRetrieveXCTestSymbol(const char *name)
|
|
|
56
55
|
|
|
57
56
|
NSArray<NSString*> *FBStandardAttributeNames(void)
|
|
58
57
|
{
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
static NSArray<NSString *> *attributeNames;
|
|
59
|
+
static dispatch_once_t onceToken;
|
|
60
|
+
dispatch_once(&onceToken, ^{
|
|
61
|
+
Class xcElementSnapshotClass = NSClassFromString(@"XCElementSnapshot");
|
|
62
|
+
NSCAssert(nil != xcElementSnapshotClass, @"XCElementSnapshot class must be resolvable", xcElementSnapshotClass);
|
|
63
|
+
attributeNames = [xcElementSnapshotClass sanitizedElementSnapshotHierarchyAttributesForAttributes:nil
|
|
64
|
+
isMacOS:NO];
|
|
65
|
+
});
|
|
66
|
+
return attributeNames;
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
NSArray<NSString*> *FBCustomAttributeNames(void)
|
|
@@ -21,10 +21,16 @@ static NSLock * lock = nil;
|
|
|
21
21
|
|
|
22
22
|
@implementation XCUIApplicationProcessDelay
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
#pragma clang diagnostic push
|
|
25
|
+
#pragma clang diagnostic ignored "-Wobjc-load-method"
|
|
26
|
+
|
|
27
|
+
+ (void)load
|
|
28
|
+
{
|
|
25
29
|
lock = [[NSLock alloc] init];
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
#pragma clang diagnostic pop
|
|
33
|
+
|
|
28
34
|
+ (void)setEventLoopHasIdledDelay:(NSTimeInterval)delay
|
|
29
35
|
{
|
|
30
36
|
[lock lock];
|
|
@@ -703,8 +703,11 @@ enum GCDAsyncSocketConfig
|
|
|
703
703
|
else {
|
|
704
704
|
maxPreBufferLength = preBufferLength;
|
|
705
705
|
}
|
|
706
|
-
|
|
706
|
+
|
|
707
|
+
#pragma clang diagnostic push
|
|
708
|
+
#pragma clang diagnostic ignored "-Wvla"
|
|
707
709
|
uint8_t seq[termLength];
|
|
710
|
+
#pragma clang diagnostic pop
|
|
708
711
|
const void *termBuf = [term bytes];
|
|
709
712
|
|
|
710
713
|
NSUInteger bufLen = MIN(bytesDone, (termLength - 1));
|
|
@@ -7123,7 +7126,10 @@ static OSStatus SSLWriteFunction(SSLConnectionRef connection, const void *data,
|
|
|
7123
7126
|
{
|
|
7124
7127
|
NSArray *cipherSuites = (NSArray *)value;
|
|
7125
7128
|
NSUInteger numberCiphers = [cipherSuites count];
|
|
7129
|
+
#pragma clang diagnostic push
|
|
7130
|
+
#pragma clang diagnostic ignored "-Wvla"
|
|
7126
7131
|
SSLCipherSuite ciphers[numberCiphers];
|
|
7132
|
+
#pragma clang diagnostic pop
|
|
7127
7133
|
|
|
7128
7134
|
NSUInteger cipherIndex;
|
|
7129
7135
|
for (cipherIndex = 0; cipherIndex < numberCiphers; cipherIndex++)
|
|
@@ -39,7 +39,6 @@ FOUNDATION_EXPORT const unsigned char WebDriverAgentLib_VersionString[];
|
|
|
39
39
|
#import <WebDriverAgentLib/FBRuntimeUtils.h>
|
|
40
40
|
#import <WebDriverAgentLib/FBSession.h>
|
|
41
41
|
#import <WebDriverAgentLib/FBWebServer.h>
|
|
42
|
-
#import <WebDriverAgentLib/XCElementSnapshot+FBHelpers.h>
|
|
43
42
|
#import <WebDriverAgentLib/XCUIApplication+FBHelpers.h>
|
|
44
43
|
#import <WebDriverAgentLib/XCUIDevice+FBHelpers.h>
|
|
45
44
|
#import <WebDriverAgentLib/XCUIDevice+FBRotation.h>
|
|
Binary file
|
|
@@ -71,11 +71,7 @@
|
|
|
71
71
|
FBWaitExact(1.0);
|
|
72
72
|
NSData *result = [FBPasteboard dataForType:@"plaintext" error:&error];
|
|
73
73
|
XCTAssertNil(error);
|
|
74
|
-
|
|
75
|
-
// Pasteboard permission appears in a simulator. Not in a real device.
|
|
76
|
-
} else {
|
|
77
|
-
XCTAssertEqualObjects(textField.value, [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]);
|
|
78
|
-
}
|
|
74
|
+
XCTAssertEqualObjects(textField.value, [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]);
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
- (void)testUrlCopyPaste
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#import "FBTestMacros.h"
|
|
14
14
|
#import "FBXPath.h"
|
|
15
15
|
#import "FBXCodeCompatibility.h"
|
|
16
|
+
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
16
17
|
#import "FBXMLGenerationOptions.h"
|
|
17
18
|
#import "XCUIElement.h"
|
|
18
19
|
#import "XCUIElement+FBFind.h"
|
|
@@ -38,64 +39,70 @@
|
|
|
38
39
|
FBAssertWaitTillBecomesTrue(self.testedView.buttons.count > 0);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
- (
|
|
42
|
+
- (id<FBXCElementSnapshot>)destinationSnapshot
|
|
42
43
|
{
|
|
43
44
|
XCUIElement *matchingElement = self.testedView.buttons.fb_firstMatch;
|
|
44
45
|
FBAssertWaitTillBecomesTrue(nil != matchingElement.fb_takeSnapshot);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
id<FBXCElementSnapshot> snapshot = matchingElement.fb_takeSnapshot;
|
|
47
48
|
// Over iOS13, snapshot returns a child.
|
|
48
|
-
// The purpose of here is return a single element
|
|
49
|
-
snapshot.children =
|
|
49
|
+
// The purpose of here is return a single element to replace children with an empty array for testing.
|
|
50
|
+
snapshot.children = @[];
|
|
50
51
|
return snapshot;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
- (void)testSingleDescendantXMLRepresentation
|
|
54
55
|
{
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
id<FBXCElementSnapshot> snapshot = self.destinationSnapshot;
|
|
57
|
+
FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
|
|
58
|
+
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
|
|
59
|
+
options:nil];
|
|
57
60
|
XCTAssertNotNil(xmlStr);
|
|
58
|
-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n",
|
|
61
|
+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdEnabled ? @"true" : @"false", wrappedSnapshot.wdVisible ? @"true" : @"false", wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex];
|
|
59
62
|
XCTAssertEqualObjects(xmlStr, expectedXml);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
- (void)testSingleDescendantXMLRepresentationWithScope
|
|
63
66
|
{
|
|
64
|
-
|
|
67
|
+
id<FBXCElementSnapshot> snapshot = self.destinationSnapshot;
|
|
65
68
|
NSString *scope = @"AppiumAUT";
|
|
66
69
|
FBXMLGenerationOptions *options = [[FBXMLGenerationOptions new] withScope:scope];
|
|
67
|
-
|
|
70
|
+
FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
|
|
71
|
+
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
|
|
72
|
+
options:options];
|
|
68
73
|
XCTAssertNotNil(xmlStr);
|
|
69
|
-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope,
|
|
74
|
+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@>\n <%@ type=\"%@\" name=\"%@\" label=\"%@\" enabled=\"%@\" visible=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\" index=\"%lu\"/>\n</%@>\n", scope, wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdEnabled ? @"true" : @"false", wrappedSnapshot.wdVisible ? @"true" : @"false", wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue], wrappedSnapshot.wdIndex, scope];
|
|
70
75
|
XCTAssertEqualObjects(xmlStr, expectedXml);
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
- (void)testSingleDescendantXMLRepresentationWithoutAttributes
|
|
74
79
|
{
|
|
75
|
-
|
|
80
|
+
id<FBXCElementSnapshot> snapshot = self.destinationSnapshot;
|
|
76
81
|
FBXMLGenerationOptions *options = [[FBXMLGenerationOptions new]
|
|
77
82
|
withExcludedAttributes:@[@"visible", @"enabled", @"index", @"blabla"]];
|
|
78
|
-
|
|
83
|
+
FBXCElementSnapshotWrapper *wrappedSnapshot = [FBXCElementSnapshotWrapper ensureWrapped:snapshot];
|
|
84
|
+
NSString *xmlStr = [FBXPath xmlStringWithRootElement:wrappedSnapshot
|
|
85
|
+
options:options];
|
|
79
86
|
XCTAssertNotNil(xmlStr);
|
|
80
|
-
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n",
|
|
87
|
+
NSString *expectedXml = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<%@ type=\"%@\" name=\"%@\" label=\"%@\" accessible=\"%@\" x=\"%@\" y=\"%@\" width=\"%@\" height=\"%@\"/>\n", wrappedSnapshot.wdType, wrappedSnapshot.wdType, wrappedSnapshot.wdName, wrappedSnapshot.wdLabel, wrappedSnapshot.wdAccessible ? @"true" : @"false", [wrappedSnapshot.wdRect[@"x"] stringValue], [wrappedSnapshot.wdRect[@"y"] stringValue], [wrappedSnapshot.wdRect[@"width"] stringValue], [wrappedSnapshot.wdRect[@"height"] stringValue]];
|
|
81
88
|
XCTAssertEqualObjects(xmlStr, expectedXml);
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
- (void)testFindMatchesInElement
|
|
85
92
|
{
|
|
86
|
-
NSArray *matchingSnapshots = [FBXPath matchesWithRootElement:self.testedApplication forQuery:@"//XCUIElementTypeButton"];
|
|
93
|
+
NSArray<id<FBXCElementSnapshot>> *matchingSnapshots = [FBXPath matchesWithRootElement:self.testedApplication forQuery:@"//XCUIElementTypeButton"];
|
|
87
94
|
XCTAssertEqual([matchingSnapshots count], 5);
|
|
88
|
-
for (id<
|
|
89
|
-
XCTAssertTrue([element.wdType isEqualToString:@"XCUIElementTypeButton"]);
|
|
95
|
+
for (id<FBXCElementSnapshot> element in matchingSnapshots) {
|
|
96
|
+
XCTAssertTrue([[FBXCElementSnapshotWrapper ensureWrapped:element].wdType isEqualToString:@"XCUIElementTypeButton"]);
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
- (void)testFindMatchesInElementWithDotNotation
|
|
94
101
|
{
|
|
95
|
-
NSArray *matchingSnapshots = [FBXPath matchesWithRootElement:self.testedApplication forQuery:@".//XCUIElementTypeButton"];
|
|
102
|
+
NSArray<id<FBXCElementSnapshot>> *matchingSnapshots = [FBXPath matchesWithRootElement:self.testedApplication forQuery:@".//XCUIElementTypeButton"];
|
|
96
103
|
XCTAssertEqual([matchingSnapshots count], 5);
|
|
97
|
-
for (id<
|
|
98
|
-
XCTAssertTrue([element.wdType isEqualToString:@"XCUIElementTypeButton"]);
|
|
104
|
+
for (id<FBXCElementSnapshot> element in matchingSnapshots) {
|
|
105
|
+
XCTAssertTrue([[FBXCElementSnapshotWrapper ensureWrapped:element].wdType isEqualToString:@"XCUIElementTypeButton"]);
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
#import "FBIntegrationTestCase.h"
|
|
13
13
|
#import "FBTestMacros.h"
|
|
14
|
-
#import "XCElementSnapshot+FBHelpers.h"
|
|
15
14
|
#import "XCUIElement.h"
|
|
16
15
|
#import "XCUIElement+FBIsVisible.h"
|
|
17
16
|
#import "XCUIElement+FBUtilities.h"
|
|
18
17
|
#import "XCUIElement+FBWebDriverAttributes.h"
|
|
18
|
+
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
19
19
|
#import "FBXCodeCompatibility.h"
|
|
20
20
|
|
|
21
21
|
@interface XCElementSnapshotHelperTests : FBIntegrationTestCase
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
@"Deadlock app",
|
|
45
45
|
@"Touch",
|
|
46
46
|
]];
|
|
47
|
-
NSArray<
|
|
47
|
+
NSArray<id<FBXCElementSnapshot>> *matchingSnapshots = [[FBXCElementSnapshotWrapper ensureWrapped:self.testedView.fb_takeSnapshot]
|
|
48
|
+
fb_descendantsMatchingType:XCUIElementTypeButton];
|
|
48
49
|
XCTAssertEqual(matchingSnapshots.count, expectedLabels.count);
|
|
49
50
|
NSArray<NSString *> *labels = [matchingSnapshots valueForKeyPath:@"@distinctUnionOfObjects.label"];
|
|
50
51
|
XCTAssertEqualObjects([NSSet setWithArray:labels], expectedLabels);
|
|
@@ -58,7 +59,8 @@
|
|
|
58
59
|
{
|
|
59
60
|
XCUIElement *button = self.testedApplication.buttons[@"Alerts"];
|
|
60
61
|
FBAssertWaitTillBecomesTrue(button.exists);
|
|
61
|
-
|
|
62
|
+
id<FBXCElementSnapshot> windowSnapshot = [[FBXCElementSnapshotWrapper ensureWrapped:button.fb_takeSnapshot]
|
|
63
|
+
fb_parentMatchingType:XCUIElementTypeWindow];
|
|
62
64
|
XCTAssertNotNil(windowSnapshot);
|
|
63
65
|
XCTAssertEqual(windowSnapshot.elementType, XCUIElementTypeWindow);
|
|
64
66
|
}
|
|
@@ -84,7 +86,8 @@
|
|
|
84
86
|
{
|
|
85
87
|
XCUIElement *todayPickerWheel = self.testedApplication.pickerWheels[@"Today"];
|
|
86
88
|
FBAssertWaitTillBecomesTrue(todayPickerWheel.exists);
|
|
87
|
-
|
|
89
|
+
id<FBXCElementSnapshot> datePicker = [[FBXCElementSnapshotWrapper ensureWrapped:todayPickerWheel.fb_takeSnapshot]
|
|
90
|
+
fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeDatePicker), @(XCUIElementTypeWindow)]];
|
|
88
91
|
XCTAssertNotNil(datePicker);
|
|
89
92
|
XCTAssertEqual(datePicker.elementType, XCUIElementTypeDatePicker);
|
|
90
93
|
}
|
|
@@ -93,27 +96,17 @@
|
|
|
93
96
|
{
|
|
94
97
|
XCUIElement *todayPickerWheel = self.testedApplication.pickerWheels[@"Today"];
|
|
95
98
|
FBAssertWaitTillBecomesTrue(todayPickerWheel.exists);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// </XCUIElementTypeOther>
|
|
99
|
-
// <XCUIElementTypeDatePicker>
|
|
100
|
-
// <XCUIElementTypePicker>
|
|
101
|
-
// <XCUIElementTypePickerWheel value="Today"...>
|
|
102
|
-
otherSnapshot = [[[todayPickerWheel.fb_takeSnapshot fb_parentMatchingType:XCUIElementTypePicker]
|
|
103
|
-
fb_parentMatchingType:XCUIElementTypeDatePicker] fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny), @(XCUIElementTypeWindow)]];
|
|
104
|
-
} else {
|
|
105
|
-
otherSnapshot = [todayPickerWheel.fb_takeSnapshot fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny),
|
|
106
|
-
@(XCUIElementTypeWindow)]];
|
|
107
|
-
}
|
|
99
|
+
id<FBXCElementSnapshot> otherSnapshot =[[FBXCElementSnapshotWrapper ensureWrapped:todayPickerWheel.fb_takeSnapshot]
|
|
100
|
+
fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeAny)]];
|
|
108
101
|
XCTAssertNotNil(otherSnapshot);
|
|
109
|
-
XCTAssertEqual(otherSnapshot.elementType, XCUIElementTypeOther);
|
|
110
102
|
}
|
|
111
103
|
|
|
112
104
|
- (void)testParentMatchingOneOfTypesWithAbsentParents
|
|
113
105
|
{
|
|
114
106
|
XCUIElement *todayPickerWheel = self.testedApplication.pickerWheels[@"Today"];
|
|
115
107
|
FBAssertWaitTillBecomesTrue(todayPickerWheel.exists);
|
|
116
|
-
|
|
108
|
+
id<FBXCElementSnapshot> otherSnapshot = [[FBXCElementSnapshotWrapper ensureWrapped:todayPickerWheel.fb_takeSnapshot]
|
|
109
|
+
fb_parentMatchingOneOfTypes:@[@(XCUIElementTypeTab), @(XCUIElementTypeLink)]];
|
|
117
110
|
XCTAssertNil(otherSnapshot);
|
|
118
111
|
}
|
|
119
112
|
|
|
@@ -143,10 +136,11 @@
|
|
|
143
136
|
@(XCUIElementTypeCollectionView),
|
|
144
137
|
@(XCUIElementTypeTable),
|
|
145
138
|
];
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
id<FBXCElementSnapshot> scrollView = [[FBXCElementSnapshotWrapper ensureWrapped:threeStaticText.fb_takeSnapshot]
|
|
140
|
+
fb_parentMatchingOneOfTypes:acceptedParents
|
|
141
|
+
filter:^BOOL(id<FBXCElementSnapshot> snapshot) {
|
|
142
|
+
return [[FBXCElementSnapshotWrapper ensureWrapped:snapshot] isWDVisible];
|
|
143
|
+
}];
|
|
150
144
|
XCTAssertEqualObjects(scrollView.identifier, @"scrollView");
|
|
151
145
|
}
|
|
152
146
|
|
|
@@ -159,10 +153,11 @@
|
|
|
159
153
|
@(XCUIElementTypeCollectionView),
|
|
160
154
|
@(XCUIElementTypeTable),
|
|
161
155
|
];
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
id<FBXCElementSnapshot> scrollView = [[FBXCElementSnapshotWrapper ensureWrapped:threeStaticText.fb_takeSnapshot]
|
|
157
|
+
fb_parentMatchingOneOfTypes:acceptedParents
|
|
158
|
+
filter:^BOOL(id<FBXCElementSnapshot> snapshot) {
|
|
159
|
+
return NO;
|
|
160
|
+
}];
|
|
166
161
|
XCTAssertNil(scrollView);
|
|
167
162
|
}
|
|
168
163
|
|
|
@@ -170,9 +165,9 @@
|
|
|
170
165
|
{
|
|
171
166
|
XCUIElement *scrollView = self.testedApplication.scrollViews[@"scrollView"];
|
|
172
167
|
FBAssertWaitTillBecomesTrue(self.testedApplication.staticTexts[@"3"].fb_isVisible);
|
|
173
|
-
NSArray *cells = [scrollView.fb_takeSnapshot fb_descendantsCellSnapshots];
|
|
168
|
+
NSArray *cells = [[FBXCElementSnapshotWrapper ensureWrapped:scrollView.fb_takeSnapshot] fb_descendantsCellSnapshots];
|
|
174
169
|
XCTAssertGreaterThanOrEqual(cells.count, 10);
|
|
175
|
-
|
|
170
|
+
id<FBXCElementSnapshot> element = cells.firstObject;
|
|
176
171
|
XCTAssertEqualObjects(element.label, @"0");
|
|
177
172
|
}
|
|
178
173
|
|
|
@@ -197,7 +192,7 @@
|
|
|
197
192
|
{
|
|
198
193
|
FBAssertWaitTillBecomesTrue(self.testedApplication.staticTexts[@"3"].fb_isVisible);
|
|
199
194
|
XCUIElement *threeStaticText = self.testedApplication.staticTexts[@"3"];
|
|
200
|
-
|
|
195
|
+
id<FBXCElementSnapshot> xcuiElementCell = [[FBXCElementSnapshotWrapper ensureWrapped:threeStaticText.fb_takeSnapshot] fb_parentCellSnapshot];
|
|
201
196
|
XCTAssertEqual(xcuiElementCell.elementType, 75);
|
|
202
197
|
}
|
|
203
198
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
#import "FBIntegrationTestCase.h"
|
|
11
11
|
#import "FBTestMacros.h"
|
|
12
|
-
#import "
|
|
12
|
+
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
13
13
|
#import "XCUIElement.h"
|
|
14
14
|
#import "XCUIElement+FBUtilities.h"
|
|
15
15
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
[self launchApplication];
|
|
24
24
|
[self goToAttributesPage];
|
|
25
25
|
XCUIElement *dstBtn = self.testedApplication.buttons[@"not_accessible"];
|
|
26
|
-
CGPoint hitPoint = dstBtn.fb_takeSnapshot.fb_hitPoint.CGPointValue;
|
|
26
|
+
CGPoint hitPoint = [FBXCElementSnapshotWrapper ensureWrapped:dstBtn.fb_takeSnapshot].fb_hitPoint.CGPointValue;
|
|
27
27
|
XCTAssertTrue(hitPoint.x > 0 && hitPoint.y > 0);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
#import "FBTestMacros.h"
|
|
16
16
|
#import "XCUIElement.h"
|
|
17
17
|
#import "XCUIElement+FBFind.h"
|
|
18
|
-
#import "
|
|
18
|
+
#import "FBXCElementSnapshotWrapper+Helpers.h"
|
|
19
19
|
#import "XCUIElement+FBIsVisible.h"
|
|
20
20
|
#import "XCUIElement+FBClassChain.h"
|
|
21
21
|
#import "XCUIElement+FBResolve.h"
|
|
@@ -182,7 +182,8 @@
|
|
|
182
182
|
- (void)testDescendantsWithPredicateString
|
|
183
183
|
{
|
|
184
184
|
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"label = 'Alerts'"];
|
|
185
|
-
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingPredicate:predicate
|
|
185
|
+
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingPredicate:predicate
|
|
186
|
+
shouldReturnAfterFirstMatch:NO];
|
|
186
187
|
int snapshotsCount = 1;
|
|
187
188
|
if (@available(iOS 13.0, *)) {
|
|
188
189
|
snapshotsCount = 2;
|
|
@@ -191,7 +192,8 @@
|
|
|
191
192
|
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
|
|
192
193
|
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
|
|
193
194
|
NSPredicate *selfPredicate = [NSPredicate predicateWithFormat:@"label == 'Alerts'"];
|
|
194
|
-
NSArray<XCUIElement *> *selfElementsByPredicate = [matchingSnapshots.lastObject fb_descendantsMatchingPredicate:selfPredicate
|
|
195
|
+
NSArray<XCUIElement *> *selfElementsByPredicate = [matchingSnapshots.lastObject fb_descendantsMatchingPredicate:selfPredicate
|
|
196
|
+
shouldReturnAfterFirstMatch:NO];
|
|
195
197
|
XCTAssertEqual(selfElementsByPredicate.count, 1);
|
|
196
198
|
}
|
|
197
199
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#import "FBTestMacros.h"
|
|
16
16
|
#import "FBElement.h"
|
|
17
17
|
#import "FBElementUtils.h"
|
|
18
|
+
#import "FBXCElementSnapshot.h"
|
|
18
19
|
#import "XCUIElement+FBUtilities.h"
|
|
19
20
|
|
|
20
21
|
@interface XCUIElementHelperIntegrationTests : FBIntegrationTestCase
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
[allElements addObjectsFromArray:buttons];
|
|
41
42
|
[allElements addObjectsFromArray:windows];
|
|
42
43
|
|
|
43
|
-
NSMutableArray<
|
|
44
|
+
NSMutableArray<id<FBXCElementSnapshot>> *buttonSnapshots = [NSMutableArray array];
|
|
44
45
|
[buttonSnapshots addObject:[buttons.firstObject fb_takeSnapshot]];
|
|
45
46
|
|
|
46
47
|
NSArray<XCUIElement *> *result = [self.testedApplication fb_filterDescendantsWithSnapshots:buttonSnapshots selfUID:nil onlyChildren:NO];
|
|
@@ -7,19 +7,8 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
#import <
|
|
11
|
-
|
|
12
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
-
|
|
14
|
-
@interface XCElementSnapshot (FBHitPoint)
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
Wrapper for Apple's hitpoint, thats resolves few known issues
|
|
18
|
-
|
|
19
|
-
@return Element's hitpoint if exists nil otherwise
|
|
20
|
-
*/
|
|
21
|
-
- (nullable NSValue *)fb_hitPoint;
|
|
10
|
+
#import <XCTest/XCTest.h>
|
|
22
11
|
|
|
12
|
+
@interface XCElementSnapshotDouble : NSObject<XCUIElementAttributes>
|
|
13
|
+
@property (readwrite, nullable) id value;
|
|
23
14
|
@end
|
|
24
|
-
|
|
25
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,99 @@
|
|
|
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 "XCElementSnapshotDouble.h"
|
|
11
|
+
|
|
12
|
+
#import "FBXCAccessibilityElement.h"
|
|
13
|
+
#import "FBXCElementSnapshot.h"
|
|
14
|
+
|
|
15
|
+
@implementation XCElementSnapshotDouble
|
|
16
|
+
|
|
17
|
+
- (id)init
|
|
18
|
+
{
|
|
19
|
+
self = [super init];
|
|
20
|
+
self->_value = @"magicValue";
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (NSString *)identifier
|
|
25
|
+
{
|
|
26
|
+
return @"testName";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (CGRect)frame
|
|
30
|
+
{
|
|
31
|
+
return CGRectZero;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
- (NSString *)title
|
|
35
|
+
{
|
|
36
|
+
return @"testTitle";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (NSString *)label
|
|
40
|
+
{
|
|
41
|
+
return @"testLabel";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (XCUIElementType)elementType
|
|
45
|
+
{
|
|
46
|
+
return XCUIElementTypeOther;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (BOOL)isEnabled
|
|
50
|
+
{
|
|
51
|
+
return YES;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (XCUIUserInterfaceSizeClass)horizontalSizeClass
|
|
55
|
+
{
|
|
56
|
+
return XCUIUserInterfaceSizeClassUnspecified;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
- (XCUIUserInterfaceSizeClass)verticalSizeClass
|
|
60
|
+
{
|
|
61
|
+
return XCUIUserInterfaceSizeClassUnspecified;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (NSString *)placeholderValue
|
|
65
|
+
{
|
|
66
|
+
return @"";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (BOOL)isSelected
|
|
70
|
+
{
|
|
71
|
+
return YES;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (BOOL)hasFocus
|
|
75
|
+
{
|
|
76
|
+
return YES;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (NSDictionary *)additionalAttributes
|
|
80
|
+
{
|
|
81
|
+
return @{};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (id<FBXCAccessibilityElement>)accessibilityElement
|
|
85
|
+
{
|
|
86
|
+
return nil;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
- (id<FBXCElementSnapshot>)parent
|
|
90
|
+
{
|
|
91
|
+
return nil;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (NSArray *)children
|
|
95
|
+
{
|
|
96
|
+
return @[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@end
|