Best EarlGrey code snippet using performAction.grey_scrollToContentEdgeWithStartPoint
FTRScrollViewTest.m
Source:FTRScrollViewTest.m
...54 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];55}56- (void)testScrollToLeftEdgeWithCustomStartPoint {57 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]58 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeLeft, 0.5, 0.5)];59 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]60 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];61}62- (void)testScrollToRightEdgeWithCustomStartPoint {63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]64 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeRight, 0.5, 0.5)];65 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]66 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];67}68- (void)testScrollToTopEdgeWithCustomStartPoint {69 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]70 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeTop, 0.5, 0.5)];71 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]72 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];73}74- (void)testScrollToBottomEdgeWithCustomStartPoint {75 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]76 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeBottom, 0.5, 0.5)];77 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]78 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];79}80- (void)testScrollToTopWorksWithPositiveInsets {81 // Scroll down.82 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),83 grey_sufficientlyVisible(), nil);84 [[[EarlGrey selectElementWithMatcher:matcher]85 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)86 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]87 assertWithMatcher:grey_sufficientlyVisible()];88 // Add positive insets using this format {top,left,bottom,right}89 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]90 performAction:grey_typeText(@"{100,0,0,0}\n")];...
ScrollViewTest.m
Source:ScrollViewTest.m
...54 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];55}56- (void)testScrollToLeftEdgeWithCustomStartPoint {57 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]58 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeLeft, 0.5, 0.5)];59 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]60 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeLeft)];61}62- (void)testScrollToRightEdgeWithCustomStartPoint {63 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]64 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeRight, 0.5, 0.5)];65 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]66 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeRight)];67}68- (void)testScrollToTopEdgeWithCustomStartPoint {69 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]70 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeTop, 0.5, 0.5)];71 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]72 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeTop)];73}74- (void)testScrollToBottomEdgeWithCustomStartPoint {75 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]76 performAction:grey_scrollToContentEdgeWithStartPoint(kGREYContentEdgeBottom, 0.5, 0.5)];77 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Bottom Scroll View")]78 assertWithMatcher:grey_scrolledToContentEdge(kGREYContentEdgeBottom)];79}80- (void)testScrollToTopWorksWithPositiveInsets {81 // Scroll down.82 id<GREYMatcher> matcher = grey_allOf(grey_accessibilityLabel(@"Label 2"), grey_interactable(),83 grey_sufficientlyVisible(), nil);84 [[[EarlGrey selectElementWithMatcher:matcher]85 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)86 onElementWithMatcher:grey_accessibilityLabel(@"Upper Scroll View")]87 assertWithMatcher:grey_sufficientlyVisible()];88 // Add positive insets using this format {top,left,bottom,right}89 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"topTextbox")]90 performAction:grey_typeText(@"{100,0,0,0}\n")];...
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"accessibilityID")] performAction:grey_scrollToContentEdgeWithStartPoint(GREYContentEdgeTop)];2[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"accessibilityID")] performAction:grey_scrollToContentEdge(GREYContentEdgeTop)];3EarlGrey.selectElement(with: grey_accessibilityID("accessibilityID")).perform(grey_scrollToContentEdgeWithStartPoint(GREYContentEdgeTop))4EarlGrey.selectElement(with: grey_accessibilityID("accessibilityID")).perform(grey_scrollToContentEdge(GREYContentEdgeTop))5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"accessibilityID")] performAction:grey_scrollToContentEdgeWithStartPoint(GREYContentEdgeTop)];6EarlGrey.selectElement(with: grey_accessibilityID("accessibilityID")).perform(grey_scrollToContentEdgeWithStartPoint(GREYContentEdgeTop))
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]2 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), kGREYContentEdgeTop)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]4 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), kGREYContentEdgeBottom)];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]6 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), kGREYContentEdgeLeft)];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]8 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), kGREYContentEdgeRight)];9[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]10 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), kGREYContentEdgeNone)];11GREY_EXTERN id<GREYAction> grey_scrollToContentEdgeWithStartPoint(CGPoint startPoint,12 GREYContentEdge edge);13GREY_EXTERN id<GREYAction> grey_scrollToContentEdgeWithStartPoint(CGPoint startPoint,14 GREYContentEdge edge);15id<GREYAction> grey_scrollToContentEdgeWithStartPoint(CGPoint startPoint,16 GREYContentEdge edge) {17 return [GREYScrollAction actionWithEdge:startPoint edge:edge];18}
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1GREYActionBlock* grey_scrollToContentEdgeWithStartPoint = ^BOOL (id element, NSError *__strong *errorOrNil) {2 if (![element isKindOfClass:[UIScrollView class]]) {3 return NO;4 }5 UIScrollView* scrollView = (UIScrollView*)element;6 CGPoint startPoint = CGPointMake(0.5, 0.5);7 CGPoint contentOffset = scrollView.contentOffset;8 CGSize contentSize = scrollView.contentSize;9 CGSize frameSize = scrollView.frame.size;10 CGPoint endPoint = CGPointMake(0.5, 0.5);11 if (contentOffset.y + frameSize.height < contentSize.height) {12 endPoint.y = 0.0;13 }14 if (contentOffset.x + frameSize.width < contentSize.width) {15 endPoint.x = 0.0;16 }17 [scrollView setContentOffset:endPoint animated:YES];18 return YES;19};20GREYActionBlock* grey_scrollToContentEdgeWithStartPoint = ^BOOL (id element, NSError *__strong *errorOrNil) {21 if (![element isKindOfClass:[UIScrollView class]]) {22 return NO;23 }24 UIScrollView* scrollView = (UIScrollView*)element;25 CGPoint startPoint = CGPointMake(0.5, 0.5);26 CGPoint contentOffset = scrollView.contentOffset;27 CGSize contentSize = scrollView.contentSize;28 CGSize frameSize = scrollView.frame.size;29 CGPoint endPoint = CGPointMake(0.5, 0.5);30 if (contentOffset.y + frameSize.height < contentSize.height) {31 endPoint.y = 0.0;32 }33 if (contentOffset.x + frameSize.width < contentSize.width) {34 endPoint.x = 0.0;35 }36 [scrollView setContentOffset:endPoint animated:YES];37 return YES;38};39GREYActionBlock* grey_scrollToContentEdgeWithStartPoint = ^BOOL (id element, NSError *__strong *errorOrNil) {40 if (![element isKindOfClass:[UIScrollView class]]) {41 return NO;42 }43 UIScrollView* scrollView = (UIScrollView*)element;44 CGPoint startPoint = CGPointMake(0.5, 0.5);45 CGPoint contentOffset = scrollView.contentOffset;46 CGSize contentSize = scrollView.contentSize;
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(0.5, 0.5, 0.5, 0.5)];2+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGFloat)startX3 startPointY:(CGFloat)startY4 endPointX:(CGFloat)endX5 endPointY:(CGFloat)endY;6+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGFloat)startX7 startPointY:(CGFloat)startY8 endPointX:(CGFloat)endX9 endPointY:(CGFloat)endY {10 constraints:grey_interactable()11 performBlock:^BOOL (id element, NSError *__strong *errorOrNil) {12 if (![element conformsToProtocol:@protocol(UIScrollView)]) {13 "UIScrollView protocol: %@", element];14 GREYPopulateErrorNotedOrLog(errorOrNil,15 reason);16 return NO;17 }18 UIScrollView *scrollView = (UIScrollView *)element;19 CGPoint startPoint = CGPointMake(startX, startY);20 CGPoint endPoint = CGPointMake(endX, endY);21 [scrollView setContentOffset:startPoint];22 [scrollView setContentOffset:endPoint];23 return YES;24 }];25}26+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGFloat)startX27 startPointY:(CGFloat)startY28 endPointX:(CGFloat)endX29 endPointY:(CGFloat)endY;30+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGFloat)startX31 startPointY:(CGFloat)startY
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"test-Scroll")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];2+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGPoint)startPoint {3 return [GREYActionBlock actionWithName:[NSString stringWithFormat:@"Scroll to content edge (%f, %f)", startPoint.x, startPoint.y]4 constraints:grey_allOf(grey_interactable(), grey_not(grey_systemAlertViewShown()), nil)5 perform:^BOOL (id element, __strong NSError *__strong *errorOrNil) {6 UIScrollView *scrollView = (UIScrollView *)element;7 CGPoint contentOffset = [scrollView contentOffset];8 CGPoint contentSize = [scrollView contentSize];9 CGPoint frameSize = [scrollView frame].size;10 if (startPoint.x == 0.5 && startPoint.y == 0.5) {11 contentOffset.x = contentSize.x/2 - frameSize.x/2;12 contentOffset.y = contentSize.y/2 - frameSize.y/2;13 } else if (startPoint.x == 0.5 && startPoint.y == 0) {14 contentOffset.x = contentSize.x/2 - frameSize.x/2;15 contentOffset.y = 0;16 } else if (startPoint.x == 0 && startPoint.y == 0.5) {17 contentOffset.x = 0;18 contentOffset.y = contentSize.y/2 - frameSize.y/2;19 } else if (startPoint.x == 0.5 && startPoint.y == 1) {20 contentOffset.x = contentSize.x/2 - frameSize.x/2;21 contentOffset.y = contentSize.y - frameSize.y;22 } else if (startPoint.x == 1 && startPoint.y == 0.5) {23 contentOffset.x = contentSize.x - frameSize.x;24 contentOffset.y = contentSize.y/2 - frameSize.y/2;25 } else if (startPoint.x == 1 && startPoint.y == 0) {
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]2 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]4 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]6 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]8 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];9[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]10 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];11[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]12 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];13[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]14 performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];15[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")]
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollableTable")]2performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5))];3+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGPoint)point;4+ (id<GREYAction>)grey_scrollToContentEdgeWithStartPoint:(CGPoint)point {5 return [GREYActionBlock actionWithName:[NSString stringWithFormat:@"Scroll to content edge with start point: %@", NSStringFromCGPoint(point)]6 constraints:grey_respondsToSelector(@selector(scrollToContentEdgeWithStartPoint:))7 performBlock:^BOOL(id element, NSError *__strong *errorOrNil) {8 return [element scrollToContentEdgeWithStartPoint:point];9 }];10}11- (instancetype)performAction:(id<GREYAction>)action {12 [self assertWithMatcher:self.matcher];13 NSString *actionName = [action name];14 [GREYThrowOnFailure(self.matcher) assertMatchForElement:self.element actionName:actionName];15 [GREYThrowOnFailure(action) assertForElement:self.element];16 NSError *error;17 BOOL success = [action perform:self.element error:&error];18 if (!success) {19 actionName, self.element];20 GREYFail(reason, error);21 }22 return self;23}24- (
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeTop)];2[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeBottom)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeLeft)];4[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeRight)];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeTop)];6[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContentEdgeWithStartPoint(CGPointMake(0.5, 0.5), GREYContentEdgeBottom)];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollview")] performAction:grey_scrollToContent
grey_scrollToContentEdgeWithStartPoint
Using AI Code Generation
1performAction *action = [performAction new];2[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeBottom];3performAction *action = [performAction new];4[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeTop];5performAction *action = [performAction new];6[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeLeft];7performAction *action = [performAction new];8[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeRight];9performAction *action = [performAction new];10[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeTopLeft];11performAction *action = [performAction new];12[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeTopRight];13performAction *action = [performAction new];14[action grey_scrollToContentEdgeWithStartPoint:GREYContentEdgeBottomLeft];15performAction *action = [performAction new];
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!