How to use grey_longPressAtPointWithDuration method of performAction class

Best EarlGrey code snippet using performAction.grey_longPressAtPointWithDuration

BasicInteractionTest.m

Source:BasicInteractionTest.m Github

copy

Full Screen

...494- (void)testLongPressAtPointOnAccessibilityElement {495 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];496 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];497 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Long Press")]498 performAction:grey_longPressAtPointWithDuration(CGPointMake(10, 10), 1.1f)]499 assertWithMatcher:grey_nil()];500}501/**502 * Checks long press on a text field.503 */504- (void)testLongPressOnTextField {505 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];506 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];507 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]508 performAction:grey_longPressWithDuration(1.0f)];509 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] assertWithMatcher:grey_notNil()];510}511/**512 * Check long pressing followed by selecting a menu option.513 */514- (void)testLongPressFollowedBySelectingMenuOption {515 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];516 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];517 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]518 performAction:grey_typeText(@"Hello")];519 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]520 performAction:grey_longPressAtPointWithDuration(CGPointMake(1, 1), 1.0f)];521 [[EarlGrey selectElementWithMatcher:grey_text(@"Select")] performAction:grey_tap()];522 [[EarlGrey selectElementWithMatcher:grey_text(@"Cut")] performAction:grey_tap()];523 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]524 performAction:grey_typeText(@"FromEarlGrey")];525 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]526 performAction:grey_longPressAtPointWithDuration(CGPointMake(1, 1), 1.0f)];527 [[EarlGrey selectElementWithMatcher:grey_text(@"Paste")] performAction:grey_tap()];528 // Smart Inserts in Xcode 9 cause a space to appear by default after a paste. This attribute529 // is not available on Xcode 7 and therefore cannot be used to fix the test. Therefore, we530 // are changing the value based on the Xcode version.531 if (iOS11_OR_ABOVE()) {532 [[EarlGrey selectElementWithMatcher:grey_text(@"Hello FromEarlGrey")]533 assertWithMatcher:grey_sufficientlyVisible()];534 } else {535 [[EarlGrey selectElementWithMatcher:grey_text(@"HelloFromEarlGrey")]536 assertWithMatcher:grey_sufficientlyVisible()];537 }538}539/**540 * Check interaction with a view that has its parent view hidden and unhidden....

Full Screen

Full Screen

FTRBasicInteractionTest.m

Source:FTRBasicInteractionTest.m Github

copy

Full Screen

...485- (void)testLongPressAtPointOnAccessibilityElement {486 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];487 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];488 [[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Long Press")]489 performAction:grey_longPressAtPointWithDuration(CGPointMake(10, 10), 1.1f)]490 assertWithMatcher:grey_nil()];491}492/**493 * Checks long press on a text field.494 */495- (void)testLongPressOnTextField {496 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];497 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];498 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]499 performAction:grey_longPressWithDuration(1.0f)];500 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] assertWithMatcher:grey_notNil()];501}502/**503 * Check long pressing followed by selecting a menu option.504 */505- (void)testLongPressFollowedBySelectingMenuOption {506 [[EarlGrey selectElementWithMatcher:grey_text(@"Basic Views")] performAction:grey_tap()];507 [[EarlGrey selectElementWithMatcher:grey_text(@"Tab 2")] performAction:grey_tap()];508 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]509 performAction:grey_typeText(@"Hello")];510 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]511 performAction:grey_longPressAtPointWithDuration(CGPointMake(1, 1), 1.0f)];512 [[EarlGrey selectElementWithMatcher:grey_text(@"Select")] performAction:grey_tap()];513 [[EarlGrey selectElementWithMatcher:grey_text(@"Cut")] performAction:grey_tap()];514 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]515 performAction:grey_typeText(@"FromEarlGrey")];516 [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"foo")]517 performAction:grey_longPressAtPointWithDuration(CGPointMake(1, 1), 1.0f)];518 [[EarlGrey selectElementWithMatcher:grey_text(@"Paste")] performAction:grey_tap()];519 // Smart Inserts in Xcode 9 cause a space to appear by default after a paste. This attribute520 // is not available on Xcode 7 and therefore cannot be used to fix the test. Therefore, we521 // are changing the value based on the Xcode version.522 if (iOS11_OR_ABOVE()) {523 [[EarlGrey selectElementWithMatcher:grey_text(@"Hello FromEarlGrey")]524 assertWithMatcher:grey_sufficientlyVisible()];525 } else {526 [[EarlGrey selectElementWithMatcher:grey_text(@"HelloFromEarlGrey")]527 assertWithMatcher:grey_sufficientlyVisible()];528 }529}530/**531 * Check interaction with a view that has its parent view hidden and unhidden....

Full Screen

Full Screen

GestureTest.m

Source:GestureTest.m Github

copy

Full Screen

...89 CGPointMake(midX, CGRectGetMinY(targetBounds) - 1),90 CGPointMake(midX, CGRectGetMaxY(targetBounds) + 1)};91 for (NSInteger i = 0; i < 4; i++) {92 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]93 performAction:grey_longPressAtPointWithDuration(outsidePoints[i], 1.0)];94 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"single long press")]95 assertWithMatcher:grey_nil()];96 }97 // Verify that tapping inside the bounds causes the long press.98 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]99 performAction:grey_longPressAtPointWithDuration(CGPointMake(midX, midX), 1.0)];100 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"single long press")]101 assertWithMatcher:grey_sufficientlyVisible()];102}103- (void)testSwipeWorksInAllDirectionsInPortraitMode {104 [self ftr_assertSwipeWorksInAllDirections];105}106- (void)testSwipeWorksInAllDirectionsInUpsideDownMode {107 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortraitUpsideDown error:nil];108 [self ftr_assertSwipeWorksInAllDirections];109}110- (void)testSwipeWorksInAllDirectionsInLandscapeLeftMode {111 [EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft error:nil];112 [self ftr_assertSwipeWorksInAllDirections];113}...

Full Screen

Full Screen

FTRGestureTest.m

Source:FTRGestureTest.m Github

copy

Full Screen

...67 CGPointMake(midX, CGRectGetMaxY(targetBounds) + 1)68 };69 for (NSInteger i = 0; i < 4; i++) {70 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]71 performAction:grey_longPressAtPointWithDuration(outsidePoints[i], 0.5f)];72 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"single long press")]73 assertWithMatcher:grey_nil()];74 }75 // Verify that tapping inside the bounds causes the long press.76 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Grey Box")]77 performAction:grey_longPressAtPointWithDuration(CGPointMake(midX, midX), 0.5f)];78 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"single long press")]79 assertWithMatcher:grey_sufficientlyVisible()];80}81// Asserts that the given gesture has been recognised regardless of the gesture's start point.82- (void)grey_assertGestureRecognized:(NSString *)gesture {83 MatchesBlock gestureMatcherBlock = ^BOOL (id element) {84 NSString *text = [(UILabel *)element text];85 GREYAssert([text hasPrefix:gesture], @"Gesture prefix '%@' not found in '%@'.", gesture, text);86 return YES;87 };88 DescribeToBlock gestureMatcherDescriptionBlock = ^(id<GREYDescription> description) {89 [description appendText:@"Gesture Matcher"];90 };91 GREYElementMatcherBlock *gestureElementMatcher =...

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"buttonID")] performAction:grey_longPressAtPointWithDuration(CGPointMake(0, 0), 1.0)];2+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point3 duration:(CFTimeInterval)duration;4+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point5 duration:(CFTimeInterval)duration;6+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point7 duration:(CFTimeInterval)duration {8 tappableUI:YES];9}10- (instancetype)init NS_UNAVAILABLE;11- (instancetype)initWithDuration:(CFTimeInterval)duration12 point:(CGPoint)point13 tappableUI:(BOOL)tappable NS_DESIGNATED_INITIALIZER;14- (instancetype)initWithDuration:(CFTimeInterval)duration15 point:(CGPoint)point16 tappableUI:(BOOL)tappable {17 NSString *name = [NSString stringWithFormat:@"Long press at point (%g, %g) for %g seconds",

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"button")]2 performAction:grey_longPressAtPointWithDuration(CGPointMake(0, 0), 3.0)];3[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"button")]4 performAction:grey_longPressAtPointWithDuration(CGPointMake(0, 0), 3.0)];5[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"button")]6 performAction:grey_longPressWithDuration(3.0)];7[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"button")]8 performAction:grey_longPress()];9[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"slider")]10 performAction:grey_moveSliderToValue(0.5)];11[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"slider")]12 performAction:grey_moveSliderToNormalizedValue(0.5)];13[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollView")]14 performAction:grey_scrollInDirection(kGREYDirectionDown, 100)];15[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollView")]16 performAction:grey_scrollToContentEdge(kGREYContentEdgeTop)];17[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"scrollView")]18 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myButton")]2performAction:grey_longPressAtPointWithDuration(CGPointMake(0.5, 0.5), 0.5)];3+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point4 duration:(CFTimeInterval)duration;5+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point6 duration:(CFTimeInterval)duration {7 NSStringFromCGPoint(point), duration]8 constraints:grey_not(grey_systemAlertViewShown())9 performBlock:^BOOL(id element, __strong NSError *__strong *errorOrNil) {10 GREYThrowOnFailedConditionWithMessage([element isKindOfClass:[UIView class]],11 element);12 UIView *view = element;13 CGPoint location = CGPointMake(CGRectGetWidth(view.bounds) * point.x,14 CGRectGetHeight(view.bounds) * point.y);15 return [GREYActions grey_longPress:view atPoint:location duration:duration];16 }];17}18+ (BOOL)grey_longPress:(UIView *)view atPoint:(CGPoint)point duration:(CFTimeInterval)duration {19 inView:view];20 CFTimeInterval initialTime = CACurrentMediaTime();21 CFTimeInterval currentTime = initialTime;22 while (currentTime - initialTime < duration) {23 inView:view];24 CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01, false);25 currentTime = CACurrentMediaTime();26 }27 inView:view];

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1[[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"myElement")]2 performAction:grey_longPressAtPointWithDuration(CGPointMake(50, 50), 5.0)];3+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point4 duration:(CFTimeInterval)duration;5+ (id<GREYAction>)grey_longPressAtPointWithDuration:(CGPoint)point6 duration:(CFTimeInterval)duration {7 locationProvider:^CGPoint(CGSize size) {8 return point;9 }];10}11+ (id<GREYAction>)grey_actionForMultipleTapsWithCount:(NSUInteger)count12 duration:(CFTimeInterval)duration13 locationName:(NSString *)locationName14 locationProvider:(CGPoint (^)(CGSize))locationProvider;15+ (id<GREYAction>)grey_actionForMultipleTapsWithCount:(NSUInteger)count16 duration:(CFTimeInterval)duration17 locationName:(NSString *)locationName18 locationProvider:(CGPoint (^)(CGSize))locationProvider {19 tapCount:1];20}21+ (id<GREYAction>)grey_actionForMultipleTapsWithCount:(NSUInteger)count22 duration:(CFTimeInterval)duration23 locationName:(NSString *)locationName24 locationProvider:(CGPoint (^)(CGSize))locationProvider25 tapCount:(NSUInteger)tapCount;26+ (id<GREY

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1#import "EarlGrey.h"2#import "GREYMatchers.h"3#import "GREYActions.h"4#import "GREYConstants.h"5#import "GREYConfiguration.h"6#import "GREYElementInteraction.h"7#import "GREYElementMatcherBlock.h"8#import "GREYElementMatcher.h"9#import "GREYInteraction.h"10#import "GREYMatchers.h"11#import "GREYAppStateTracker.h"12#import "GREYAppStateTrackerObject.h"13#define grey_longPressAtPointWithDuration(point, duration) \14#import "EarlGrey.h"15#import "GREYMatchers.h"16#import "GREYActions.h"17#import "GREYConstants.h"18#import "GREYConfiguration.h"19#import "GREYElementInteraction.h"20#import "GREYElementMatcherBlock.h"21#import "GREYElementMatcher.h"22#import "GREYInteraction.h"23#import "GREYMatchers.h"24#import "GREYAppStateTracker.h"25#import "GREYAppStateTrackerObject.h"26#define grey_doubleTap() \27#import "EarlGrey.h"28#import "GREYMatchers.h"29#import "GREYActions.h"30#import "GREYConstants.h"31#import "GREYConfiguration.h"32#import "GREYElementInteraction.h"33#import "GREYElementMatcherBlock.h"34#import "GREYElementMatcher.h"35#import "GREYInteraction.h"36#import "GREYMatchers.h"37#import "GREYAppStateTracker.h"38#import "GREYAppStateTrackerObject.h"39#define grey_doubleTapAtPoint(point) \40#import "EarlGrey.h"41#import "GREYMatchers.h"42#import "GREYActions.h"43#import "GREYConstants.h"44#import "GREYConfiguration.h"45#import "GREYElementInteraction.h"46#import "GREYElementMatcherBlock.h"47#import "GREYElementMatcher.h"48#import "GREYInteraction.h"49#import "GREYMatchers.h"50#import "GREYAppStateTracker.h"51#import "GREYAppStateTrackerObject.h"

Full Screen

Full Screen

grey_longPressAtPointWithDuration

Using AI Code Generation

copy

Full Screen

1 [EarlGrey selectElementWithMatcher:grey_accessibilityID(@"labelID")]2 .performAction([GREYActions grey_longPressAtPoint:CGPointMake(100, 100) duration:1.0]);3 constraints:grey_not(grey_systemAlertViewShown())4 performBlock:^BOOL (id element, NSError *__strong *errorOrNil) {5 if (![element isKindOfClass:[UIView class]]) {6 return NO;7 }8 UIView *view = (UIView *)element;9 CGPoint point = CGPointMake(CGRectGetWidth(view.bounds) / 2,10 CGRectGetHeight(view.bounds) / 2);11 point = [view convertPoint:point toView:nil];12 error:errorOrNil];13 }];14 constraints:grey_not(grey_systemAlertViewShown())15 performBlock:^BOOL (id element, NSError *__strong *errorOrNil) {16 if (![element isKindOfClass:[UIView class]]) {17 return NO;18 }19 UIView *view = (UIView *)element;20 CGPoint point = CGPointMake(CGRectGetWidth(view.bounds) / 2,21 CGRectGetHeight(view.bounds) / 2);22 point = [view convertPoint:point toView:nil];23 error:errorOrNil];24 }];25 + (BOOL)longPressAtPoint:(CGPoint)point26 duration:(CFTimeInterval)duration27 error:(__strong NSError **)error;28 + (BOOL)longPressAtPoint:(CGPoint)point29 duration:(CFTimeInterval)duration30 error:(__strong NSError **)error {

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful