GREYActions
@interface GREYActions : NSObject
A interface that exposes UI element actions.
-
Declaration
Objective-C
+ (id<GREYAction>)actionForMultipleTapsWithCount:(NSUInteger)count;
Return Value
A GREYAction that performs multiple taps of a specified @c count.
-
Declaration
Objective-C
+ (id<GREYAction>)actionForMultipleTapsWithCount:(NSUInteger)count atPoint:(CGPoint)point;
Return Value
A GREYAction that performs multiple taps of a specified @c count at a specified @c point.
-
Returns an action that holds down finger for 1.0 second (@c kGREYLongPressDefaultDuration) to simulate a long press.
Declaration
Objective-C
+ (id<GREYAction>)actionForLongPress;
Return Value
A GREYAction that performs a long press on an element.
-
Returns an action that holds down finger for specified @c duration to simulate a long press.
Declaration
Objective-C
+ (id<GREYAction>)actionForLongPressWithDuration:(CFTimeInterval)duration;
Parameters
duration
The duration of the long press.
Return Value
A GREYAction that performs a long press on an element.
-
Returns an action that holds down finger for specified @c duration at the specified @c point (interpreted as being relative to the element) to simulate a long press.
Declaration
Objective-C
+ (id<GREYAction>)actionForLongPressAtPoint:(CGPoint)point duration:(CFTimeInterval)duration;
Parameters
point
The point that should be tapped.
duration
The duration of the long press.
Return Value
A GREYAction that performs a long press on an element.
-
Returns an action that scrolls a @c UIScrollView by @c amount (in points) in the specified @c direction.
Declaration
Objective-C
+ (id<GREYAction>)actionForScrollInDirection:(GREYDirection)direction amount:(CGFloat)amount;
Parameters
direction
The direction of the swipe.
amount
The amount of points in CGPoints to scroll.
Return Value
A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount.
-
Returns a scroll action that scrolls in a @c direction for an @c amount of points starting from the given start point specified as percentages. @c xOriginStartPercentage is the x start position as a percentage of the total width of the scrollable visible area, @c yOriginStartPercentage is the y start position as a percentage of the total height of the scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between 0 and 1, exclusive.
Declaration
Objective-C
+ (id<GREYAction>)actionForScrollInDirection:(GREYDirection)direction amount:(CGFloat)amount xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
direction
The direction of the scroll.
amount
The amount scroll in points to inject.
xOriginStartPercentage
X coordinate of the start point specified as a percentage (0, 1) exclusive, of the total width of the scrollable visible area.
yOriginStartPercentage
Y coordinate of the start point specified as a percentage (0, 1) exclusive, of the total height of the scrollable visible area.
Return Value
A GREYAction that scrolls a scroll view in a given @c direction for a given @c amount starting from the given start points.
-
Declaration
Objective-C
+ (id<GREYAction>)actionForScrollToContentEdge:(GREYContentEdge)edge;
Return Value
A GREYAction that scrolls to the given content @c edge of a scroll view.
-
A GREYAction that scrolls to the given content @c edge of a scroll view with the scroll action starting from the given start point specified as percentages. @c xOriginStartPercentage is the x start position as a percentage of the total width of the scrollable visible area, @c yOriginStartPercentage is the y start position as a percentage of the total height of the scrollable visible area. @c xOriginStartPercentage and @c yOriginStartPercentage must be between 0 and 1, exclusive.
Declaration
Objective-C
+ (id<GREYAction>)actionForScrollToContentEdge:(GREYContentEdge)edge xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
edge
The edge towards which the scrolling is to take place.
xOriginStartPercentage
X coordinate of the start point specified as a percentage (0, 1) exclusive, of the total width of the scrollable visible area.
yOriginStartPercentage
Y coordinate of the start point specified as a percentage (0, 1) exclusive, of the total height of the scrollable visible area.
Return Value
A GREYAction that scrolls to the given content @c edge of a scroll view with the scroll action starting from the given start point.
-
Returns an action that fast swipes through the view. The start point of the swipe is chosen to achieve the maximum the swipe possible to the other edge.
Declaration
Objective-C
+ (id<GREYAction>)actionForSwipeFastInDirection:(GREYDirection)direction;
Parameters
direction
The direction of the swipe.
Return Value
A GREYAction that performs a fast swipe in the given direction.
-
Returns an action that slow swipes through the view. The start point of the swipe is chosen to achieve maximum the swipe possible to the other edge.
Declaration
Objective-C
+ (id<GREYAction>)actionForSwipeSlowInDirection:(GREYDirection)direction;
Parameters
direction
The direction of the swipe.
Return Value
A GREYAction that performs a slow swipe in the given direction.
-
Returns an action that swipes through the view quickly in the given @c direction from a specific origin.
Declaration
Objective-C
+ (id<GREYAction>)actionForSwipeFastInDirection:(GREYDirection)direction xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
direction
The direction of the swipe.
xOriginStartPercentage
the x start position as a percentage of the total width of the view. This must be between 0 and 1.
yOriginStartPercentage
the y start position as a percentage of the total height of the view. This must be between 0 and 1.
Return Value
A GREYAction that performs a fast swipe through a view in a specific direction from the specified point.
-
Returns an action that swipes through the view quickly in the given @c direction from a specific origin.
Declaration
Objective-C
+ (id<GREYAction>)actionForSwipeSlowInDirection:(GREYDirection)direction xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
direction
The direction of the swipe.
xOriginStartPercentage
the x start position as a percentage of the total width of the view. This must be between 0 and 1.
yOriginStartPercentage
the y start position as a percentage of the total height of the view. This must be between 0 and 1.
Return Value
A GREYAction that performs a slow swipe through a view in a specific direction from the specified point.
-
Returns an action that performs a multi-finger slow swipe through the view in the given @c direction.
Declaration
Objective-C
+ (id<GREYAction>) actionForMultiFingerSwipeSlowInDirection:(GREYDirection)direction numberOfFingers:(NSUInteger)numberOfFingers;
Parameters
direction
The direction of the swipe.
numberOfFingers
Number of fingers touching the screen for the swipe.
Return Value
A GREYAction that performs a multi-finger slow swipe through a view in a specific direction from the specified point.
-
Returns an action that performs a multi-finger fast swipe through the view in the given @c direction.
Declaration
Objective-C
+ (id<GREYAction>) actionForMultiFingerSwipeFastInDirection:(GREYDirection)direction numberOfFingers:(NSUInteger)numberOfFingers;
Parameters
direction
The direction of the swipe.
numberOfFingers
Number of fingers touching the screen for the swipe.
Return Value
A GREYAction that performs a multi-finger fast swipe through a view in a specific direction from the specified point.
-
+actionForMultiFingerSwipeSlowInDirection:numberOfFingers:xOriginStartPercentage:yOriginStartPercentage:
Returns an action that performs a multi-finger slow swipe through the view in the given @c direction from a specified origin.
Declaration
Objective-C
+ (id<GREYAction>) actionForMultiFingerSwipeSlowInDirection:(GREYDirection)direction numberOfFingers:(NSUInteger)numberOfFingers xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
direction
The direction of the swipe.
numberOfFingers
Number of fingers touching the screen for the swipe.
xOriginStartPercentage
The x start position as a percentage of the total width of the view. This must be between 0 and 1.
yOriginStartPercentage
The y start position as a percentage of the total height of the view. This must be between 0 and 1.
Return Value
A GREYAction that performs a multi-finger slow swipe through a view in a specific direction from the specified point.
-
+actionForMultiFingerSwipeFastInDirection:numberOfFingers:xOriginStartPercentage:yOriginStartPercentage:
Returns an action that performs a multi-finger fast swipe through the view in the given @c direction from a specified origin.
Declaration
Objective-C
+ (id<GREYAction>) actionForMultiFingerSwipeFastInDirection:(GREYDirection)direction numberOfFingers:(NSUInteger)numberOfFingers xOriginStartPercentage:(CGFloat)xOriginStartPercentage yOriginStartPercentage:(CGFloat)yOriginStartPercentage;
Parameters
direction
The direction of the swipe.
numberOfFingers
Number of fingers touching the screen for the swipe.
xOriginStartPercentage
The x start position as a percentage of the total width of the view. This must be between 0 and 1.
yOriginStartPercentage
The y start position as a percentage of the total height of the view. This must be between 0 and 1.
Return Value
A GREYAction that performs a multi-finger fast swipe through a view in a specific direction from the specified point.
-
Returns an action that pinches view quickly in the specified @c direction and @c angle.
Declaration
Objective-C
+ (id<GREYAction>)actionForPinchFastInDirection: (GREYPinchDirection)pinchDirection withAngle:(double)angle;
Parameters
pinchDirection
The direction of the pinch action.
angle
The angle of the pinch action in radians. Use @c kGREYPinchAngleDefault for the default angle (currently set to 30 degrees).
Return Value
A GREYAction that performs a fast pinch on the view in the specified @c direction.
-
Returns an action that pinches view slowly in the specified @c direction and @c angle.
Declaration
Objective-C
+ (id<GREYAction>)actionForPinchSlowInDirection: (GREYPinchDirection)pinchDirection withAngle:(double)angle;
Parameters
pinchDirection
The direction of the pinch action.
angle
The angle of the pinch action in radians. Use @c kGREYPinchAngleDefault for the default angle (currently set to 30 degrees).
Return Value
A GREYAction that performs a slow pinch on the view in the specified @c direction.
-
Returns an action that attempts to move slider to within 1.0e-6f values of @c value.
Declaration
Objective-C
+ (id<GREYAction>)actionForMoveSliderToValue:(float)value;
Parameters
value
The value to which the slider should be moved. If this is not attainable after a reasonable number of attempts (currently 10) we assume that the @c value is unattainable for a user (it is probably the case this value resides between two pixels). In this case, the slider will end up at a user attainable value that is closest to @c value.
Return Value
A GREYAction that moves a slider to a given @c value.
-
Returns an action that changes the value of UIStepper to @c value by tapping the appropriate button multiple times.
Declaration
Objective-C
+ (id<GREYAction>)actionForSetStepperValue:(double)value;
Parameters
value
The value to change the UIStepper to.
Return Value
A GREYAction that sets the given @c value on a stepper.
-
Returns an action that taps on an element at the activation point of the element.
Declaration
Objective-C
+ (id<GREYAction>)actionForTap;
Return Value
A GREYAction to tap on an element.
-
Returns an action that taps on an element at the specified @c point.
Declaration
Objective-C
+ (id<GREYAction>)actionForTapAtPoint:(CGPoint)point;
Parameters
point
The point that should be tapped. It must be in the coordinate system of the element and it’s position is relative to the origin of the element, as in (element_width/2, element_height/2) will tap at the center of element.
Return Value
A GREYAction to tap on an element at a specific point.
-
Returns an action that uses the iOS keyboard to input a string.
Declaration
Objective-C
+ (id<GREYAction>)actionForTypeText:(NSString *)text;
Parameters
text
The text to be typed. For Objective-C, backspace is supported by using
\b
in the string and\u{8}
in Swift strings. Return key is supported with\n
. For Example: @Helpo\b\bloWorld
will type HelloWorld in Objective-C.Helpo\u{8}\u{8}loWorld
will type HelloWorld in Swift.Return Value
A GREYAction to type a specific text string in a text field.
-
Returns an action that sets text on a UITextField or webview input directly.
Declaration
Objective-C
+ (id<GREYAction>)actionForReplaceText:(NSString *)text;
Parameters
text
The text to be typed.
Return Value
A GREYAction to type a specific text string in a text field.
-
Declaration
Objective-C
+ (id<GREYAction>)actionForClearText;
Return Value
A GREYAction that clears a text field by injecting back-spaces.
-
Returns an action that toggles a switch control. This action is applicable to all elements that implement the selector UISwitch::isOn and include UISwitch controls.
Declaration
Objective-C
+ (id<GREYAction>)actionForTurnSwitchOn:(BOOL)on;
Parameters
on
The switch control state.
Return Value
A GREYAction to toggle a UISwitch.
-
Returns an action that injects dates/times into UIDatePickers.
Declaration
Objective-C
+ (id<GREYAction>)actionForSetDate:(NSDate *)date;
Parameters
date
The date to set the UIDatePicker.
Return Value
A GREYAction that sets a given date/time on a UIDatePicker.
-
Returns an action that selects @c value on the given @c column of a UIPickerView.
Declaration
Objective-C
+ (id<GREYAction>)actionForSetPickerColumn:(NSInteger)column toValue:(NSString *)value;
Parameters
column
The UIPickerView column being set.
value
The value to set the UIPickerView.
Return Value
A GREYAction to set the value of a specified column of a UIPickerView.
-
Returns an action that executes JavaScript against a UIWebView and sets the return value to @c outResult if provided.
Declaration
Objective-C
+ (id<GREYAction>)actionForJavaScriptExecution:(NSString *)js output:(out NSString **)outResult;
Parameters
js
The Javascript code to be executed.
outResult
The result of the code execution.
Return Value
A GREYAction that executes JavaScript code against a UIWebView.
-
Returns an action that takes a snapshot of the selected element.
Declaration
Objective-C
+ (id<GREYAction>)actionForSnapshot:(out UIImage **)outImage;
Parameters
outImage
The UIImage where the image content is stored.
Return Value
A GREYAction that takes a snapshot of an UI element.