Files
custom_wda/WebDriverAgentTests/IntegrationTests/XCUIElementHelperIntegrationTests.m
2026-02-03 16:52:44 +08:00

52 lines
1.6 KiB
Objective-C

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <XCTest/XCTest.h>
#import "XCTest/XCUIElementTypes.h"
#import "FBIntegrationTestCase.h"
#import "FBTestMacros.h"
#import "FBElement.h"
#import "FBElementUtils.h"
#import "FBXCElementSnapshot.h"
#import "XCUIElement+FBUtilities.h"
@interface XCUIElementHelperIntegrationTests : FBIntegrationTestCase
@end
@implementation XCUIElementHelperIntegrationTests
- (void)setUp
{
[super setUp];
[self launchApplication];
[self goToAlertsPage];
}
- (void)testDescendantsFiltering
{
NSArray<XCUIElement *> *buttons = self.testedApplication.buttons.allElementsBoundByIndex;
XCTAssertTrue(buttons.count > 0);
NSArray<XCUIElement *> *windows = self.testedApplication.windows.allElementsBoundByIndex;
XCTAssertTrue(windows.count > 0);
NSMutableArray<XCUIElement *> *allElements = [NSMutableArray array];
[allElements addObjectsFromArray:buttons];
[allElements addObjectsFromArray:windows];
NSMutableArray<id<FBXCElementSnapshot>> *buttonSnapshots = [NSMutableArray array];
[buttonSnapshots addObject:[buttons.firstObject fb_customSnapshot]];
NSArray<XCUIElement *> *result = [self.testedApplication fb_filterDescendantsWithSnapshots:buttonSnapshots
onlyChildren:NO];
XCTAssertEqual(1, result.count);
XCTAssertEqual([result.firstObject elementType], XCUIElementTypeButton);
}
@end