Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove old iOS/Xcode related test code and errors #890

Merged
merged 7 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions WebDriverAgentLib/Commands/FBElementCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@ + (NSArray *)routes
{
FBElementCache *elementCache = request.session.elementCache;
XCUIElement *element = [self targetFromRequest:request];
if (![element respondsToSelector:@selector(pressForDuration:thenDragToElement:withVelocity:thenHoldForDuration:)]) {
return FBResponseWithStatus([FBCommandStatus unsupportedOperationErrorWithMessage:@"This method is only supported in Xcode 12 and above"
traceback:nil]);
}
[element pressForDuration:[request.arguments[@"pressDuration"] doubleValue]
thenDragToElement:[elementCache elementForUUID:(NSString *)request.arguments[@"toElement"]]
withVelocity:[request.arguments[@"velocity"] doubleValue]
Expand All @@ -370,10 +366,6 @@ + (NSArray *)routes
(CGFloat)[request.arguments[@"fromY"] doubleValue]);
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset
element:session.activeApplication];
if (![startCoordinate respondsToSelector:@selector(pressForDuration:thenDragToCoordinate:withVelocity:thenHoldForDuration:)]) {
return FBResponseWithStatus([FBCommandStatus unsupportedOperationErrorWithMessage:@"This method is only supported in Xcode 12 and above"
traceback:nil]);
}
CGVector endOffset = CGVectorMake((CGFloat)[request.arguments[@"toX"] doubleValue],
(CGFloat)[request.arguments[@"toY"] doubleValue]);
XCUICoordinate *endCoordinate = [self.class gestureCoordinateWithOffset:endOffset
Expand Down
11 changes: 3 additions & 8 deletions WebDriverAgentTests/IntegrationTests/FBElementAttributeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@ - (void)testContainerAccessibilityAttributes
XCUIElement *inaccessibleButtonElement = self.testedApplication.buttons[@"not_accessible"];
XCTAssertTrue(inaccessibleButtonElement.exists);
XCTAssertFalse(inaccessibleButtonElement.fb_isAccessibilityElement);
if (@available(iOS 13.0, *)) {
// FIXME: Xcode 11 environment returns false even if iOS 12
// We must fix here to XCTAssertTrue if Xcode version will return the value properly
XCTAssertFalse(inaccessibleButtonElement.isWDAccessibilityContainer);
} else {
// Xcode 10 and the below works fine
XCTAssertTrue(inaccessibleButtonElement.isWDAccessibilityContainer);
}
// FIXME: Xcode 11 environment returns false even if iOS 12
// We must fix here to XCTAssertTrue if Xcode version will return the value properly
XCTAssertFalse(inaccessibleButtonElement.isWDAccessibilityContainer);
}

- (void)testIgnoredAccessibilityAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ - (void)disabled_testIconsFromSearchDashboard

- (void)testTableViewCells
{
if (SYSTEM_VERSION_GREATER_THAN(@"12.0")) {
// The test is flacky on iOS 12+ in Travis env
return;
}
Comment on lines -66 to -69
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test worked on my local. lets bring them back


[self launchApplication];
[self goToScrollPageWithCells:YES];
for (int i = 0 ; i < 10 ; i++) {
Expand Down
60 changes: 15 additions & 45 deletions WebDriverAgentTests/IntegrationTests/XCUIElementFBFindTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ - (void)testDescendantsWithIdentifier
{
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingIdentifier:@"Alerts"
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand Down Expand Up @@ -162,10 +159,7 @@ - (void)testDescendantsWithComplexXPathQuery
{
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingXPathQuery:@"//*[@label='Scrolling']/preceding::*[boolean(string(@label))]"
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 3;
if (@available(iOS 13.0, *)) {
snapshotsCount = 6;
}
int snapshotsCount = 6;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
}

Expand Down Expand Up @@ -198,10 +192,7 @@ - (void)testDescendantsWithPredicateString
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"label = 'Alerts'"];
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingPredicate:predicate
shouldReturnAfterFirstMatch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand Down Expand Up @@ -243,10 +234,7 @@ - (void)testDescendantsWithPropertyStrict
partialSearch:NO];
XCTAssertEqual(matchingSnapshots.count, 0);
matchingSnapshots = [self.testedView fb_descendantsMatchingProperty:@"label" value:@"Alerts" partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -259,10 +247,7 @@ - (void)testGlobalWithPropertyStrict
partialSearch:NO];
XCTAssertEqual(matchingSnapshots.count, 0);
matchingSnapshots = [self.testedApplication fb_descendantsMatchingProperty:@"label" value:@"Alerts" partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -273,10 +258,7 @@ - (void)testDescendantsWithPropertyPartial
NSArray<XCUIElement *> *matchingSnapshots = [self.testedView fb_descendantsMatchingProperty:@"label"
value:@"Alerts"
partialSearch:NO];
int snapshotsCount = 1;
if (@available(iOS 13.0, *)) {
snapshotsCount = 2;
}
int snapshotsCount = 2;
XCTAssertEqual(matchingSnapshots.count, snapshotsCount);
XCTAssertEqual(matchingSnapshots.firstObject.elementType, XCUIElementTypeButton);
XCTAssertEqualObjects(matchingSnapshots.lastObject.label, @"Alerts");
Expand All @@ -297,19 +279,13 @@ - (void)testDescendantsWithClassChain
- (void)testDescendantsWithClassChainWithIndex
{
NSArray<XCUIElement *> *matchingSnapshots;
NSString *queryString = @"XCUIElementTypeWindow/*/*[2]/*/*/XCUIElementTypeButton";
if (@available(iOS 13.0, *)) {
// iPhone
queryString = @"XCUIElementTypeWindow/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
if (matchingSnapshots.count == 0) {
// iPad
queryString = @"XCUIElementTypeWindow/*/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
}
} else {
// iPhone
NSString *queryString = @"XCUIElementTypeWindow/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
if (matchingSnapshots.count == 0) {
// iPad
queryString = @"XCUIElementTypeWindow/*/*/*/*/*[2]/*/*/XCUIElementTypeButton";
matchingSnapshots = [self.testedApplication fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
}
Expand Down Expand Up @@ -444,21 +420,15 @@ - (void)setUp

- (void)testNestedQueryWithClassChain
{
NSString *queryString = @"XCUIElementTypeOther";
if (@available(iOS 13.0, *)) {
queryString = @"XCUIElementTypePicker";
}
NSString *queryString = @"XCUIElementTypePicker";
FBAssertWaitTillBecomesTrue(self.testedApplication.buttons[@"Button"].fb_isVisible);
XCUIElement *datePicker = [self.testedApplication
descendantsMatchingType:XCUIElementTypeDatePicker].allElementsBoundByIndex.firstObject;
NSArray<XCUIElement *> *matches = [datePicker fb_descendantsMatchingClassChain:queryString
shouldReturnAfterFirstMatch:NO];
XCTAssertEqual(matches.count, 1);

XCUIElementType expectedType = XCUIElementTypeOther;
if (@available(iOS 13.0, *)) {
expectedType = XCUIElementTypePicker;
}
XCUIElementType expectedType = XCUIElementTypePicker;
XCTAssertEqual([matches firstObject].elementType, expectedType);
}

Expand Down
Loading