How to use grey_anyOf method of selectElementWithMatcher class

Best EarlGrey code snippet using selectElementWithMatcher.grey_anyOf

FTRLocalUIWebViewTest.m

Source:FTRLocalUIWebViewTest.m Github

copy

Full Screen

...55 [self ftr_waitForWebElementWithName:@"ALL" elementMatcher:grey_accessibilityLabel(@"ALL")];56 // Clicking on "Next page" triggers AJAX loading. On some form factors, label is set to "Next"57 // instead of "Next page".58 id<GREYMatcher> nextLabelMatcher =59 grey_anyOf(grey_accessibilityLabel(@"Next page"), grey_accessibilityLabel(@"Next"), nil);60 id<GREYMatcher> nextPageMatcher = grey_allOf(nextLabelMatcher, grey_interactable(), nil);61 NSError *error;62 [[[EarlGrey selectElementWithMatcher:nextPageMatcher]63 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 200)64 onElementWithMatcher:grey_kindOfClass([UIWebView class])] performAction:grey_tap()65 error:&error];66 if (error) {67 id<GREYMatcher> moreResultsMatcher = grey_accessibilityLabel(@"More results");68 [[[EarlGrey selectElementWithMatcher:grey_allOf(moreResultsMatcher, grey_interactable(), nil)]69 usingSearchAction:grey_scrollInDirection(kGREYDirectionUp, 200)70 onElementWithMatcher:grey_kindOfClass([UIWebView class])] performAction:grey_tap()];71 } else {72 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"IMAGES")]73 assertWithMatcher:grey_sufficientlyVisible()];...

Full Screen

Full Screen

FTRRemoteInteractionsTest.m

Source:FTRRemoteInteractionsTest.m Github

copy

Full Screen

...124 }125 descriptionBlock:^(id<GREYDescription> _Nonnull description) {126 [description appendText:@"Test"];127 }];128 [[[EarlGrey selectElementWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)] atIndex:0]129 assertWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)];130}131- (void)testErrorsOnSimpleRemoteMatcherWithEarlGreyCombinationMatchers {132 GREYElementMatcherBlock *allOfMatcherBlock = [GREYElementMatcherBlock133 matcherWithMatchesBlock:^BOOL(id _Nonnull element) {134 return NO;135 }136 descriptionBlock:^(id<GREYDescription> _Nonnull description) {137 [description appendText:@"Test"];138 }];139 NSError *error;140 [[EarlGrey selectElementWithMatcher:grey_allOf(grey_keyWindow(), allOfMatcherBlock, nil)]141 assertWithMatcher:grey_allOf(grey_notNil(), allOfMatcherBlock, nil)142 error:&error];143 XCTAssertNotNil(error);144 XCTAssertEqualObjects(error.domain, kGREYInteractionErrorDomain);145 GREYElementMatcherBlock *anyOfMatcherBlock = [GREYElementMatcherBlock146 matcherWithMatchesBlock:^BOOL(id _Nonnull element) {147 return NO;148 }149 descriptionBlock:^(id<GREYDescription> _Nonnull description) {150 [description appendText:@"Test"];151 }];152 [[[EarlGrey selectElementWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)] atIndex:0]153 assertWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)154 error:&error];155 XCTAssertNotNil(error);156 XCTAssertEqualObjects(error.domain, kGREYInteractionErrorDomain);157}158@end...

Full Screen

Full Screen

PerfContollerTests.m

Source:PerfContollerTests.m Github

copy

Full Screen

...105 statusLabelAccessibilityItemWithConnectionName:connectionName];106 BOOL (^conditionBlock)(void) = ^BOOL {107 NSError *error = nil;108 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(item.accessibilityID)]109 assertWithMatcher:grey_anyOf(grey_text(@"Success"), grey_text(@"Fail"), nil)110 error:&error];111 if (error) {112 NSLog(@"EarlGrey synchronization: status label hasn't been updated yet");113 }114 return error == nil;115 };116 BOOL succeeded = [[GREYCondition conditionWithName:@"Wait for status label to change text"117 block:conditionBlock] waitWithTimeout:30];118 XCTAssertTrue(succeeded);119 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(item.accessibilityID)]120 assertWithMatcher:grey_text(@"Success")];121}122- (void)tapCountButtonsNTimes:(NSUInteger)tapsCount {123 for (int counterTapNumber = 0; counterTapNumber < tapsCount; counterTapNumber++) {...

Full Screen

Full Screen

RemoteInteractionsTest.m

Source:RemoteInteractionsTest.m Github

copy

Full Screen

...124 }125 descriptionBlock:^(id<GREYDescription> _Nonnull description) {126 [description appendText:@"Test"];127 }];128 [[[EarlGrey selectElementWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)] atIndex:0]129 assertWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)];130}131- (void)testErrorsOnSimpleRemoteMatcherWithEarlGreyCombinationMatchers {132 GREYElementMatcherBlock *allOfMatcherBlock = [GREYElementMatcherBlock133 matcherWithMatchesBlock:^BOOL(id _Nonnull element) {134 return NO;135 }136 descriptionBlock:^(id<GREYDescription> _Nonnull description) {137 [description appendText:@"Test"];138 }];139 NSError *error;140 [[EarlGrey selectElementWithMatcher:grey_allOf(grey_keyWindow(), allOfMatcherBlock, nil)]141 assertWithMatcher:grey_allOf(grey_notNil(), allOfMatcherBlock, nil)142 error:&error];143 XCTAssertNotNil(error);144 XCTAssertEqualObjects(error.domain, kGREYInteractionErrorDomain);145 GREYElementMatcherBlock *anyOfMatcherBlock = [GREYElementMatcherBlock146 matcherWithMatchesBlock:^BOOL(id _Nonnull element) {147 return NO;148 }149 descriptionBlock:^(id<GREYDescription> _Nonnull description) {150 [description appendText:@"Test"];151 }];152 [[[EarlGrey selectElementWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)] atIndex:0]153 assertWithMatcher:grey_anyOf(anyOfMatcherBlock, grey_notNil(), nil)154 error:&error];155 XCTAssertNotNil(error);156 XCTAssertEqualObjects(error.domain, kGREYInteractionErrorDomain);157}158@end...

Full Screen

Full Screen

EarlGreyImplTest.m

Source:EarlGreyImplTest.m Github

copy

Full Screen

...77/**78 * Sanity check for RMI calls for matcher and action shorthand calls.79 */80- (void)testSelectElementWithMatcherWithRMICall {81 XCTAssertNoThrow(grey_anyOf(grey_interactable(), grey_firstResponder(), nil));82 XCTAssertNoThrow(grey_allOf(grey_accessibilityID(@"Text Field"), grey_interactable(), nil));83 XCTAssertNotNil([EarlGrey selectElementWithMatcher:grey_allOf(grey_accessibilityID(@"Text Field"),84 grey_interactable(), nil)]);85 XCTAssertNoThrow(({86 [[EarlGrey selectElementWithMatcher:grey_keyWindow()]87 assertWithMatcher:grey_sufficientlyVisible()];88 }));89 XCTAssertThrows(({ [[EarlGrey selectElementWithMatcher:grey_keyWindow()] performAction:nil]; }));90 XCTAssertThrows(91 ({ [[EarlGrey selectElementWithMatcher:grey_keyWindow()] assertWithMatcher:nil]; }));92 XCTAssertThrows(({93 [[[EarlGrey selectElementWithMatcher:grey_keyWindow()] performAction:grey_tap()]94 usingSearchAction:nil95 onElementWithMatcher:grey_keyWindow()];...

Full Screen

Full Screen

FTREarlGreyImplTest.m

Source:FTREarlGreyImplTest.m Github

copy

Full Screen

...77/**78 * Sanity check for RMI calls for matcher and action shorthand calls.79 */80- (void)testSelectElementWithMatcherWithRMICall {81 XCTAssertNoThrow(grey_anyOf(grey_interactable(), grey_firstResponder(), nil));82 XCTAssertNoThrow(grey_allOf(grey_accessibilityID(@"Text Field"), grey_interactable(), nil));83 XCTAssertNotNil([EarlGrey selectElementWithMatcher:grey_allOf(grey_accessibilityID(@"Text Field"),84 grey_interactable(), nil)]);85 XCTAssertNoThrow(({86 [[EarlGrey selectElementWithMatcher:grey_keyWindow()]87 assertWithMatcher:grey_sufficientlyVisible()];88 }));89 XCTAssertThrows(({ [[EarlGrey selectElementWithMatcher:grey_keyWindow()] performAction:nil]; }));90 XCTAssertThrows(91 ({ [[EarlGrey selectElementWithMatcher:grey_keyWindow()] assertWithMatcher:nil]; }));92 XCTAssertThrows(({93 [[[EarlGrey selectElementWithMatcher:grey_keyWindow()] performAction:grey_tap()]94 usingSearchAction:nil95 onElementWithMatcher:grey_keyWindow()];...

Full Screen

Full Screen

EarlGreyContribsTests.m

Source:EarlGreyContribsTests.m Github

copy

Full Screen

...16@interface EarlGreyContribsTests : XCTestCase17@end18@implementation EarlGreyContribsTests19- (void)tearDown {20 [[EarlGrey selectElementWithMatcher:grey_anyOf(grey_text(@"EarlGreyContribTestApp"),21 grey_text(@"Back"),22 nil)]23 performAction:grey_tap()];24 [super tearDown];25}26- (void)testBasicViewController {27 [[[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")]28 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)29 onElementWithMatcher:grey_kindOfClass([UITableView class])]30 performAction:grey_tap()];31 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"textField")]32 performAction:grey_typeText(@"Foo")];33 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"showButton")]34 performAction:grey_tap()];...

Full Screen

Full Screen

SetupTests.m

Source:SetupTests.m Github

copy

Full Screen

...6- (void)testBleManager {7 GREYCondition *waitForStatus = [GREYCondition conditionWithName:@"wait for loading finish" block:^BOOL{8 NSError *error;9 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TestCaseStatus")]10 assertWithMatcher:grey_anyOf(11 grey_accessibilityLabel(@"success"),12 grey_accessibilityLabel(@"failure"),13 nil14 ) error:&error];15 return error == nil;16 }];17 18 [waitForStatus waitWithTimeout:60];19 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"TestCaseStatus")]20 assertWithMatcher:grey_accessibilityLabel(@"success")];21}22@end...

Full Screen

Full Screen

grey_anyOf

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_anyOf(grey_buttonTitle(@"Cancel"), grey_buttonTitle(@"Done"), nil)] performAction:grey_tap()];2[[EarlGrey selectElementWithMatcher:grey_allOf(grey_buttonTitle(@"Cancel"), grey_buttonTitle(@"Done"), nil)] performAction:grey_tap()];3[[EarlGrey selectElementWithMatcher:grey_not(grey_buttonTitle(@"Cancel"))] performAction:grey_tap()];4[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Cancel")] performAction:grey_tap()];5[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Cancel")] performAction:grey_tap()];6[[EarlGrey selectElementWithMatcher:grey_accessibilityTrait(UIAccessibilityTraitButton)] performAction:grey_tap()];7[[EarlGrey selectElementWithMatcher:grey_accessibilityValue(@"Cancel")] performAction:grey_tap()];

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run EarlGrey automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful