Skip to content

Instantly share code, notes, and snippets.

@mjarvis
Created January 10, 2017 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mjarvis/ff3c1ab8e5826eb1e7e8b773881dcd0f to your computer and use it in GitHub Desktop.
Save mjarvis/ff3c1ab8e5826eb1e7e8b773881dcd0f to your computer and use it in GitHub Desktop.
KIF tester autocomplete in Swift
import UIKit
protocol SystemTestActor {
/*!
@abstract Waits for a specific NSNotification.
@discussion Useful when a test requires an asynchronous task to complete, especially when that task does not trigger a visible change in the view hierarchy.
@param name The name of the NSNotification.
@param object The object to which the step should listen. Nil value will listen to all objects.
@return The detected NSNotification.
*/
func wait(forNotificationName name: String!, object: Any!) -> Notification!
/*!
@abstract Waits for a specific NSNotification, emitted during or after execution of a block.
@discussion Useful when step execution causes a notification to be emitted, but executes too quickly for waitForNotificationName: to observe it.
An observer will be registered for the notification before the block is executed.
@param name The name of the NSNotification.
@param object The object to which the step should listen. Nil value will listen to all objects.
@param block The block of code to be executed.
@return The detected NSNotification.
*/
func wait(forNotificationName name: String!, object: Any!, whileExecuting block: (() -> Swift.Void)!) -> Notification!
/*!
@abstract Simulates a memory warning.
*/
func simulateMemoryWarning()
/*!
@abstract Simulates a device rotation to a specific orentation from its last set orientation.
@discussion The first time this method is called, it will be from the device's natural orientation to the orientation described.
@param orientation The desired orientation.
*/
func simulateDeviceRotation(to orientation: UIDeviceOrientation)
/*!
@abstract Waits for the application to request a specific URL while executing a block.
@param URLString The absolute string representation of the URL to detect.
@param block The block of code to be executed.
@param returnValue The value to return from @c +[UIApplication openURL:].
*/
func waitForApplication(toOpenURL URLString: String!, whileExecuting block: (() -> Swift.Void)!, returning returnValue: Bool)
/*!
@abstract Waits for the application to request any URL while executing a block.
@param block The block of code to be executed.
@param returnValue The value to return from @c +[UIApplication openURL:].
*/
func waitForApplication(toOpenAnyURLWhileExecuting block: (() -> Swift.Void)!, returning returnValue: Bool)
/*!
@abstract Waits for the application to request any URL with the given URL Scheme while executing a block.
@param URLScheme The scheme component of the URL to detect.
@param block The block of code to be executed.
@param returnValue The value to return from @c +[UIApplication openURL:].
*/
func waitForApplicationToOpenURL(withScheme URLScheme: String!, whileExecuting block: (() -> Swift.Void)!, returning returnValue: Bool)
/*!
@abstract Captured a screenshot of the current screen and writes it to disk with an optional description.
@discussion This step will fail if the @c KIF_SCREENSHOTS environment variable is not set or if the screenshot cannot be written to disk.
@param description A description to use when writing the file to disk.
*/
func captureScreenshot(withDescription description: String!)
/*!
@abstract Backgrounds app using UIAutomation command, simulating pressing the Home button
@param duration Amount of time for a background event before the app becomes active again
*/
func deactivateApp(forDuration duration: TimeInterval)
}
import KIF
protocol TestActor {
/*!
@abstract Waits until a view or accessibility element is present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element isn't found, then the step will attempt to wait until it is. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are ignored.
If the view you want to wait for is tappable, use the -waitForTappableViewWithAccessibilityLabel: methods instead as they provide a more strict test.
@param label The accessibility label of the element to wait for.
*/
func waitForView(withAccessibilityLabel label: String!) -> UIView!
/*!
@abstract Waits until a view or accessibility element is present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element isn't found, then the step will attempt to wait until it is. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are ignored.
If the view you want to wait for is tappable, use the -waitForTappableViewWithAccessibilityLabel: methods instead as they provide a more strict test.
@param label The accessibility label of the element to wait for.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
@discardableResult
func waitForView(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits) -> UIView!
/*!
@abstract Waits until a view or accessibility element is present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element isn't found, then the step will attempt to wait until it is. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are ignored.
If the view you want to wait for is tappable, use the -waitForTappableViewWithAccessibilityLabel: methods instead as they provide a more strict test.
@param label The accessibility label of the element to wait for.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
@result A configured test step.
*/
func waitForView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits) -> UIView!
/*!
@abstract Waits until a view or accessibility element is no longer present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element is found, then the step will attempt to wait until it isn't. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are considered absent.
@param label The accessibility label of the element to wait for.
*/
func waitForAbsenceOfView(withAccessibilityLabel label: String!)
/*!
@abstract Waits until a view or accessibility element is no longer present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element is found, then the step will attempt to wait until it isn't. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are considered absent.
@param label The accessibility label of the element to wait for.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
func waitForAbsenceOfView(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits)
/*!
@abstract Waits until a view or accessibility element is no longer present.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element is found, then the step will attempt to wait until it isn't. Note that the view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are considered absent.
@param label The accessibility label of the element to wait for.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
func waitForAbsenceOfView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits)
/*!
@abstract Waits until a view or accessibility element is present and available for tapping.
@discussion The view or accessibility element with the given label is found in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Whether or not a view is tappable is based on -[UIView hitTest:].
@param label The accessibility label of the element to wait for.
*/
func waitForTappableView(withAccessibilityLabel label: String!) -> UIView!
/*!
@abstract Waits until a view or accessibility element is present and available for tapping.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Whether or not a view is tappable is based on -[UIView hitTest:].
@param label The accessibility label of the element to wait for.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
func waitForTappableView(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits) -> UIView!
/*!
@abstract Waits until a view or accessibility element is present and available for tapping.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Whether or not a view is tappable is based on -[UIView hitTest:].
@param label The accessibility label of the element to wait for.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
func waitForTappableView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits) -> UIView!
/*!
@abstract Waits for an accessibility element and its containing view based on a variety of criteria.
@discussion This method provides a more verbose API for achieving what is available in the waitForView/waitForTappableView family of methods, exposing both the found element and its containing view. The results can be used in other methods such as @c tapAccessibilityElement:inView:
@param element To be populated with the matching accessibility element when found. Can be NULL.
@param view To be populated with the matching view when found. Can be NULL.
@param label The accessibility label of the element to wait for.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
@param mustBeTappable If YES, only an element that can be tapped on will be returned.
*/
func wait(for element: AutoreleasingUnsafeMutablePointer<UIAccessibilityElement?>!, view: AutoreleasingUnsafeMutablePointer<UIView?>!, withLabel label: String!, value: String!, traits: UIAccessibilityTraits, tappable mustBeTappable: Bool)
/*!
@abstract Waits for an accessibility element and its containing view from specified root view based on a variety of criteria.
@discussion This method provides a more verbose API for achieving what is available in the waitForView/waitForTappableView family of methods, exposing both the found element and its containing view. The results can be used in other methods such as @c tapAccessibilityElement:inView:
@param element To be populated with the matching accessibility element when found. Can be NULL.
@param view To be populated with the matching view when found. Can be NULL.
@param label The accessibility label of the element to wait for.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
@param fromView The root view to start looking for accessibility element.
@param mustBeTappable If YES, only an element that can be tapped on will be returned.
*/
func wait(for element: AutoreleasingUnsafeMutablePointer<UIAccessibilityElement?>!, view: AutoreleasingUnsafeMutablePointer<UIView?>!, withLabel label: String!, value: String!, traits: UIAccessibilityTraits, fromRootView fromView: UIView!, tappable mustBeTappable: Bool)
/*!
@abstract Waits for an accessibility element and its containing view based the accessibility identifier.
@discussion This method provides a more verbose API for achieving what is available in the waitForView/waitForTappableView family of methods, exposing both the found element and its containing view. The results can be used in other methods such as @c tapAccessibilityElement:inView:
@param element To be populated with the matching accessibility element when found. Can be NULL.
@param view To be populated with the matching view when found. Can be NULL.
@param identifier The accessibility identifier of the element to wait for.
@param mustBeTappable If YES, only an element that can be tapped on will be returned.
*/
func wait(for element: AutoreleasingUnsafeMutablePointer<UIAccessibilityElement?>!, view: AutoreleasingUnsafeMutablePointer<UIView?>!, withIdentifier identifier: String!, tappable mustBeTappable: Bool)
/*!
@abstract Waits for an accessibility element and its containing view from specified root view based the accessibility identifier.
@discussion This method provides a more verbose API for achieving what is available in the waitForView/waitForTappableView family of methods, exposing both the found element and its containing view. The results can be used in other methods such as @c tapAccessibilityElement:inView:
@param element To be populated with the matching accessibility element when found. Can be NULL.
@param view To be populated with the matching view when found. Can be NULL.
@param identifier The accessibility identifier of the element to wait for.
@param fromView The root view to start looking for accessibility element.
@param mustBeTappable If YES, only an element that can be tapped on will be returned.
*/
func wait(for element: AutoreleasingUnsafeMutablePointer<UIAccessibilityElement?>!, view: AutoreleasingUnsafeMutablePointer<UIView?>!, withIdentifier identifier: String!, fromRootView fromView: UIView!, tappable mustBeTappable: Bool)
/*!
@abstract Waits for an accessibility element and its containing view based on a predicate.
@discussion This method provides a more verbose API for achieving what is available in the waitForView/waitForTappableView family of methods, exposing both the found element and its containing view. The results can be used in other methods such as @c tapAccessibilityElement:inView:
This method provides more flexability than @c waitForAccessibilityElement:view:withLabel:value:traits:tappable: but less precise error messages. This message will tell you why the method failed but not whether or not the element met some of the criteria.
@param element To be populated with the matching accessibility element when found. Can be NULL.
@param view To be populated with the matching view when found. Can be NULL.
@param predicate The predicate to match.
@param mustBeTappable If YES, only an element that can be tapped on will be returned.
*/
func wait(for element: AutoreleasingUnsafeMutablePointer<UIAccessibilityElement?>!, view: AutoreleasingUnsafeMutablePointer<UIView?>!, withElementMatching predicate: NSPredicate!, tappable mustBeTappable: Bool)
/*!
@abstract Waits until an accessibility element is no longer present.
@discussion The accessibility element matching the given predicate is found in the view hierarchy. If the element is found, then the step will attempt to wait until it isn't. Note that the associated view does not necessarily have to be visible on the screen, and may be behind another view or offscreen. Views with their hidden property set to YES are considered absent.
@param predicate The predicate to match.
*/
func waitForAbsenceOfViewWithElement(matching predicate: NSPredicate!)
/*!
@abstract Tries to guess if there are any unfinished animations and waits for a certain amount of time to let them finish.
*/
func waitForAnimationsToFinish()
/*!
@abstract Tries to guess if there are any unfinished animations and waits for a certain amount of time to let them finish.
@param timeout The maximum duration the method waits to let the animations finish.
*/
func waitForAnimationsToFinish(withTimeout timeout: TimeInterval)
/*!
@abstract Tries to guess if there are any unfinished animations and waits for a certain amount of time to let them finish.
@param timeout The maximum duration the method waits to let the animations finish.
@param stabilizationTime The time we just sleep before attempting to detect animations
*/
func waitForAnimationsToFinish(withTimeout timeout: TimeInterval, stabilizationTime: TimeInterval)
/*!
@abstract Taps a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element.
@param label The accessibility label of the element to tap.
*/
func tapView(withAccessibilityLabel label: String!)
/*!
@abstract Taps a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element.
@param label The accessibility label of the element to tap.
@param traits The accessibility traits of the element to tap. Elements that do not include at least these traits are ignored.
*/
func tapView(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits)
/*!
@abstract Taps a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element.
This variation allows finding a particular instance of an accessibility element. For example, a table view might have multiple elements with the accessibility label of "Employee", but only one that also has the accessibility value of "Bob".
@param label The accessibility label of the element to tap.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to tap. Elements that do not include at least these traits are ignored.
*/
func tapView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits)
/*!
@abstract Taps a particular view in the view heirarchy.
@discussion Unlike the -tapViewWithAccessibilityLabel: family of methods, this method allows you to tap an arbitrary element. Combined with -waitForAccessibilityElement:view:withLabel:value:traits:tappable: or +[UIAccessibilityElement accessibilityElement:view:withLabel:value:traits:tappable:error:] this provides an opportunity for more complex logic.
@param element The accessibility element to tap.
@param view The view containing the accessibility element.
*/
func tap(_ element: UIAccessibilityElement!, in view: UIView!)
/*!
@abstract Taps a stepper to either increment or decrement the stepper. Presumed that - (minus) to decrement is on the left.
@discussion This will locate the left or right half of the stepper and perform a calculated click.
@param accessibilityLabel The accessibility identifier of the view to interact with.
@param stepperDirection The direction in which to change the value of the stepper (KIFStepperDirectionIncrement | KIFStepperDirectionDecrement)
*/
func tapStepper(withAccessibilityLabel accessibilityLabel: String!, increment stepperDirection: KIFStepperDirection)
/*!
@abstract Taps the increment|decrement button of a UIStepper view in the view heirarchy.
@discussion Unlike the -tapViewWithAccessibilityLabel: family of methods, this method allows you to tap an arbitrary element. Combined with -waitForAccessibilityElement:view:withLabel:value:traits:tappable: or +[UIAccessibilityElement accessibilityElement:view:withLabel:value:traits:tappable:error:] this provides an opportunity for more complex logic.
@param element The accessibility element to tap.
@param view The view containing the accessibility element.
*/
func tapStepper(with element: UIAccessibilityElement!, increment stepperDirection: KIFStepperDirection, in view: UIView!)
/*!
@abstract Taps the screen at a particular point.
@discussion Taps the screen at a specific point. In general you should use the factory steps that tap a view based on its accessibility label, but there are situations where it's not possible to access a view using accessibility mechanisms. This step is more lenient than the steps that use the accessibility label, and does not wait for any particular view to appear, or validate that the tapped view is enabled or has interaction enabled. Because this step doesn't doesn't validate that a view is present before tapping it, it's good practice to precede this step where possible with a -waitForViewWithAccessibilityLabel: with the label for another view that should appear on the same screen.
@param screenPoint The point in screen coordinates to tap. Screen points originate from the top left of the screen.
*/
func tapScreen(at screenPoint: CGPoint)
/*!
@abstract Performs a long press on a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, touch events are simulated in the center of the view or element.
@param label The accessibility label of the element to tap.
@param duration The length of time to long press the element.
*/
func longPressView(withAccessibilityLabel label: String!, duration: TimeInterval)
/*!
@abstract Performs a long press on a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, touch events are simulated in the center of the view or element.
This variation allows finding a particular instance of an accessibility element. For example, a table view might have multiple elements with the accessibility label of "Employee", but only one that also has the accessibility value of "Bob".
@param label The accessibility label of the element to tap.
@param value The accessibility value of the element to tap.
@param duration The length of time to long press the element.
*/
func longPressView(withAccessibilityLabel label: String!, value: String!, duration: TimeInterval)
func longPress(_ element: UIAccessibilityElement!, in view: UIView!, duration: TimeInterval)
/*!
@abstract Performs a long press on a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, touch events are simulated in the center of the view or element.
This variation allows finding a particular instance of an accessibility element. For example, a table view might have multiple elements with the accessibility label of "Employee", but only one that also has the accessibility value of "Bob".
@param label The accessibility label of the element to tap.
@param value The accessibility value of the element to tap.
@param traits The accessibility traits of the element to tap. Elements that do not include at least these traits are ignored.
@param duration The length of time to long press the element.
*/
func longPressView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits, duration: TimeInterval)
/*!
@abstract Waits for the software keyboard to be visible.
@discussion If input is also possible from a hardare keyboard @c waitForKeyInputReady may be more appropriate.
*/
func waitForSoftwareKeyboard()
@available(*, deprecated, message: "Use waitForSoftwareKeyboard or waitForKeyInputReady.")
func waitForKeyboard()
/*!
@abstract If present, waits for the software keyboard to dismiss.
*/
func waitForAbsenceOfSoftwareKeyboard()
@available(*, deprecated, message: "Use waitForAbscenseOfSoftwareKeyboard.")
func waitForAbsenceOfKeyboard()
/*!
@abstract Waits for the keyboard to be ready for input. This tests whether or not a hardware or software keyboard is available and if the keyboard has a responder to send events to.
*/
func waitForKeyInputReady()
/*!
@abstract Enters text into a the current first responder.
@discussion Text is entered into the view by simulating taps on the appropriate keyboard keys if the keyboard is already displayed. Useful to enter text in UIWebViews or components with no accessibility labels.
@param text The text to enter.
*/
func enterText(intoCurrentFirstResponder text: String!)
func enterText(intoCurrentFirstResponder text: String!, fallbackView: UIView!)
/*!
@abstract Enters text into a particular view in the view hierarchy.
@discussion If the element isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element, then text is entered into the view by simulating taps on the appropriate keyboard keys.
@param text The text to enter.
@param expectedResult What the text value should be after entry, including any formatting done by the field. If this is nil, the "text" parameter will be used.
@param element the element to type into.
@param view the view to type into.
*/
func enterText(_ text: String!, into element: UIAccessibilityElement!, in view: UIView!, expectedResult: String!)
/*!
@abstract Enters text into a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element, then text is entered into the view by simulating taps on the appropriate keyboard keys.
@param text The text to enter.
@param label The accessibility label of the element to type into.
*/
func enterText(_ text: String!, intoViewWithAccessibilityLabel label: String!)
/*!
@abstract Enters text into a particular view in the view hierarchy.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, a tap event is simulated in the center of the view or element, then text is entered into the view by simulating taps on the appropriate keyboard keys.
@param text The text to enter.
@param label The accessibility label of the element to type into.
@param traits The accessibility traits of the element to type into. Elements that do not include at least these traits are ignored.
@param expectedResult What the text value should be after entry, including any formatting done by the field. If this is nil, the "text" parameter will be used.
*/
func enterText(_ text: String!, intoViewWithAccessibilityLabel label: String!, traits: UIAccessibilityTraits, expectedResult: String!)
func clearTextFromFirstResponder()
func clearTextFromView(withAccessibilityLabel label: String!)
func clearTextFromView(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits)
func clearText(from element: UIAccessibilityElement!, in view: UIView!)
func clearTextFromAndThenEnterText(intoCurrentFirstResponder text: String!)
func clearText(fromAndThenEnterText text: String!, intoViewWithAccessibilityLabel label: String!)
func clearText(fromAndThenEnterText text: String!, intoViewWithAccessibilityLabel label: String!, traits: UIAccessibilityTraits, expectedResult: String!)
/*!
@abstract Sets text into a particular view in the view hierarchy. No animation nor typing simulation.
@discussion The view or accessibility element with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present and tappable, then text is set on the view. Does not result in first responder changes. Does not perform expected result validation.
@param text The text to set.
@param label The accessibility label of the element to set the text on.
*/
func setText(_ text: String!, intoViewWithAccessibilityLabel label: String!)
/*!
@abstract Gets text from a given label/text field/text view
@param view The view to get the text from
@returns Text from the given label/text field/text view
*/
func text(from view: UIView!) -> String!
func expect(_ view: UIView!, toContainText expectedResult: String!)
/*!
@abstract Selects an item from a currently visible picker view.
@discussion With a picker view already visible, this step will find an item with the given title, select that item, and tap the Done button.
@param title The title of the row to select.
*/
func selectPickerViewRow(withTitle title: String!)
/*!
@abstract Selects an item from a currently visible picker view in specified component.
@discussion With a picker view already visible, this step will find an item with the given title in given component, select that item, and tap the Done button.
@param title The title of the row to select.
@param component The component tester inteds to select the title in.
*/
func selectPickerViewRow(withTitle title: String!, inComponent component: Int)
/*!
@abstract Selects a value from a currently visible date picker view.
@discussion With a date picker view already visible, this step will select the different rotating weel values in order of how the array parameter is passed in. After it is done it will hide the date picker. It works with all 4 UIDatePickerMode* modes. The input parameter of type NSArray has to match in what order the date picker is displaying the values/columns. So if the locale is changing the input parameter has to be adjusted. Example: Mode: UIDatePickerModeDate, Locale: en_US, Input param: NSArray *date = @[@"June", @"17", @"1965"];. Example: Mode: UIDatePickerModeDate, Locale: de_DE, Input param: NSArray *date = @[@"17.", @"Juni", @"1965".
@param datePickerColumnValues Each element in the NSArray represents a rotating wheel in the date picker control. Elements from 0 - n are listed in the order of the rotating wheels, left to right.
*/
func selectDatePickerValue(_ datePickerColumnValues: [Any]!)
/*!
@abstract Toggles a UISwitch into a specified position.
@discussion The UISwitch with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present, the step will return if it's already in the desired position. If the switch is tappable but not in the desired position, a tap event is simulated in the center of the view or element, toggling the switch into the desired position.
@param switchIsOn The desired position of the UISwitch.
@param label The accessibility label of the element to switch.
*/
func setOn(_ switchIsOn: Bool, forSwitchWithAccessibilityLabel label: String!)
/*!
@abstract Toggles a UISwitch into a specified position.
@discussion If the Switch isn't currently tappable, then the step will attempt to wait until it is. Once the view is present, the step will return if it's already in the desired position. If the switch is tappable but not in the desired position, a tap event is simulated in the center of the view or element, toggling the switch into the desired position.
@param switchIsOn The desired position of the UISwitch.
@param switchView The switch to switch.
@param element The accessibility element for the switch.
*/
func setSwitch(_ switchView: UISwitch!, element: UIAccessibilityElement!, on switchIsOn: Bool)
/*!
@abstract Slides a UISlider to a specified value.
@discussion The UISlider with the given label is searched for in the view hierarchy. If the element isn't found or isn't currently tappable, then the step will attempt to wait until it is. Once the view is present, the step will attempt to drag the slider to the new value. The step will fail if it finds a view with the given accessibility label that is not a UISlider or if value is outside of the possible values. Because this step simulates drag events, the value reached may not be the exact value requested and the app may ignore the touch events if the movement is less than the drag gesture recognizer's minimum distance.
@param value The desired value of the UISlider.
@param label The accessibility label of the element to drag.
*/
func setValue(_ value: Float, forSliderWithAccessibilityLabel label: String!)
func setValue(_ value: Float, for slider: UISlider!)
/*!
@abstract Dismisses a popover on screen.
@discussion With a popover up, tap at the top-left corner of the screen.
*/
func dismissPopover()
/*!
@abstract Select a certain photo from the built in photo picker.
@discussion This set of steps expects that the photo picker has been initiated and that the sheet is up. From there it will tap the "Choose Photo" button and select the desired photo.
@param albumName The name of the album to select the photo from. (1-indexed)
@param row The row number in the album for the desired photo. (1-indexed)
@param column The column number in the album for the desired photo.
*/
func choosePhoto(inAlbum albumName: String!, atRow row: Int, column: Int)
/*!
@abstract Taps the row at indexPath in a table view with the given label.
@discussion This step will get the view with the specified accessibility label and tap the row at indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param tableViewLabel Accessibility label of the table view.
@param indexPath Index path of the row to tap.
*/
@available(*, deprecated, message: "Use tapRowAtIndexPath:inTableViewWithAccessibilityIdentifier:")
func tapRowInTableView(withAccessibilityLabel tableViewLabel: String!, at indexPath: IndexPath!)
/*!
@abstract Taps the row at indexPath in a table view with the given identifier.
@discussion This step will get the view with the specified accessibility identifier and tap the row at indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the row to tap.
@param identifier Accessibility identifier of the table view.
*/
@available(iOS 5.0, *)
func tapRow(at indexPath: IndexPath!, inTableViewWithAccessibilityIdentifier identifier: String!)
/*!
@abstract Taps the row at indexPath in a given table view.
@discussion This step will tap the row at indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the row to tap.
@param tableView UITableView containing row to tap.
*/
func tapRow(at indexPath: IndexPath!, in tableView: UITableView!)
/*!
@abstract Taps the item at indexPath in a collection view with the given identifier.
@discussion This step will get the view with the specified accessibility identifier and tap the item at indexPath.
For cases where you may need to work from the end of a collection view rather than the beginning, negative sections count back from the end of the collection view (-1 is the last section) and negative items count back from the end of the section (-1 is the last item for that section).
@param indexPath Index path of the item to tap.
@param identifier Accessibility identifier of the collection view.
*/
func tapItem(at indexPath: IndexPath!, inCollectionViewWithAccessibilityIdentifier identifier: String!)
/*!
@abstract Taps the item at indexPath in a given collection view.
@discussion This step will get the view with the specified accessibility identifier and tap the item at indexPath.
For cases where you may need to work from the end of a collection view rather than the beginning, negative sections count back from the end of the collection view (-1 is the last section) and negative items count back from the end of the section (-1 is the last item for that section).
@param indexPath Index path of the item to tap.
@param collectionView the UICollectionView containing the item.
*/
func tapItem(at indexPath: IndexPath!, in collectionView: UICollectionView!)
/*!
@abstract If present, dismisses a system alert with the last button, usually 'Allow'. Returns YES if a dialog was dismissed, NO otherwise.
@discussion Use this to dissmiss a location services authorization dialog or a photos access dialog by tapping the 'Allow' button. No action is taken if no alert is present.
*/
func acknowledgeSystemAlert() -> Bool
/*!
@abstract Swipes a particular view in the view hierarchy in the given direction.
@discussion The view will get the view with the specified accessibility label and swipe the screen in the given direction from the view's center.
@param label The accessibility label of the view to swipe.
@param direction The direction in which to swipe.
*/
func swipeView(withAccessibilityLabel label: String!, in direction: KIFSwipeDirection)
/*!
@abstract Swipes a particular view in the view hierarchy in the given direction.
@discussion The view will get the view with the specified accessibility label and swipe the screen in the given direction from the view's center.
@param label The accessibility label of the view to swipe.
@param value The accessibility value of the view to swipe.
@param direction The direction in which to swipe.
*/
func swipeView(withAccessibilityLabel label: String!, value: String!, in direction: KIFSwipeDirection)
/*!
@abstract Swipes a particular view in the view hierarchy in the given direction.
@discussion This step will get the view with the specified accessibility label and swipe the screen in the given direction from the view's center.
@param label The accessibility label of the view to swipe.
@param value The accessibility value of the view to swipe.
@param traits The accessibility traits of the view to swipe. Elements that do not include at least these traits are ignored.
@param direction The direction in which to swipe.
*/
func swipeView(withAccessibilityLabel label: String!, value: String!, traits: UIAccessibilityTraits, in direction: KIFSwipeDirection)
/*!
@abstract Swipes a particular view in the view heirarchy.
@discussion Unlike the -swipeViewWithAccessibilityLabel: family of methods, this method allows you to swipe an arbitrary element. Combined with -waitForAccessibilityElement:view:withLabel:value:traits:tappable: or +[UIAccessibilityElement accessibilityElement:view:withLabel:value:traits:tappable:error:] this provides an opportunity for more complex logic.
@param element The accessibility element of the view to swipe.
@param viewToSwipe The view containing the accessibility element.
*/
func swipeAccessibilityElement(_ element: UIAccessibilityElement!, in viewToSwipe: UIView!, in direction: KIFSwipeDirection)
/*!
@abstract Pulls down on the view that enables the pull to refresh.
@discussion This will enact the pull to refresh by pulling down the distance of 1/2 the height of the view found by the accessibility label.
@param label The accessibility label of the view to swipe.
@param pullDownDuration The enum describing the approximate time for the pull down to travel the entire distance
*/
func pullToRefreshView(withAccessibilityLabel label: String!, pullDownDuration: KIFPullToRefreshTiming)
/*!
@abstract Pulls down on the view that enables the pull to refresh.
@discussion This will enact the pull to refresh by pulling down the distance of 1/2 the height of the view found by the accessibility label.
@param label The accessibility label of the view to swipe.
@param value The accessibility value of the view to swipe.
*/
func pullToRefreshView(withAccessibilityLabel label: String!, value: String!)
/*!
@abstract Pulls down on the view that enables the pull to refresh.
@discussion This will enact the pull to refresh by pulling down the distance of 1/2 the height of the view found by the accessibility label.
@param element The accessibility element to perform the pull down on.
@param viewToSwipe The view containing the accessibility element.
@param pullDownDuration The enum describing the approximate time for the pull down to travel the entire distance
*/
func pull(toRefreshAccessibilityElement element: UIAccessibilityElement!, in viewToSwipe: UIView!, pullDownDuration: KIFPullToRefreshTiming)
/*!
@abstract Scrolls a particular view in the view hierarchy by an amount indicated as a fraction of its size.
@discussion The view will get the view with the specified accessibility label and scroll it by the indicated fraction of its size, with the scroll centered on the center of the view.
@param label The accessibility label of the view to scroll.
@param horizontalFraction The horizontal displacement of the scroll action, as a fraction of the width of the view.
@param verticalFraction The vertical displacement of the scroll action, as a fraction of the height of the view.
*/
@available(*, deprecated, message: "Use scrollViewWithAccessibilityIdentifier:byFractionOfSizeHorizontal:vertical:")
func scrollView(withAccessibilityLabel label: String!, byFractionOfSizeHorizontal horizontalFraction: CGFloat, vertical verticalFraction: CGFloat)
/*!
@abstract Scrolls a particular view in the view hierarchy by an amount indicated as a fraction of its size.
@discussion The view will get the view with the specified accessibility identifier and scroll it by the indicated fraction of its size, with the scroll centered on the center of the view.
@param identifier The accessibility identifier of the view to scroll.
@param horizontalFraction The horizontal displacement of the scroll action, as a fraction of the width of the view.
@param verticalFraction The vertical displacement of the scroll action, as a fraction of the height of the view.
*/
@available(iOS 5.0, *)
func scrollView(withAccessibilityIdentifier identifier: String!, byFractionOfSizeHorizontal horizontalFraction: CGFloat, vertical verticalFraction: CGFloat)
/*!
@abstract Scrolls a particular view in the view hierarchy by an amount indicated as a fraction of its size.
@discussion The view will scroll by the indicated fraction of its size, with the scroll centered on the center of the view.
@param element The accessibility element of the view to scroll.
@param viewToScroll the view to scroll.
@param horizontalFraction The horizontal displacement of the scroll action, as a fraction of the width of the view.
@param verticalFraction The vertical displacement of the scroll action, as a fraction of the height of the view.
*/
func scroll(_ element: UIAccessibilityElement!, in viewToScroll: UIView!, byFractionOfSizeHorizontal horizontalFraction: CGFloat, vertical verticalFraction: CGFloat)
/*!
@abstract Waits until a view or accessibility element is the first responder.
@discussion The first responder is found by searching the view hierarchy of the application's
main window and its accessibility label is compared to the given value. If they match, the
step returns success else it will attempt to wait until they do.
@param label The accessibility label of the element to wait for.
*/
func waitForFirstResponder(withAccessibilityLabel label: String!)
/*!
@abstract Waits until a view or accessibility element is the first responder.
@discussion The first responder is found by searching the view hierarchy of the application's
main window and its accessibility label is compared to the given value. If they match, the
step returns success else it will attempt to wait until they do.
@param label The accessibility label of the element to wait for.
@param traits The accessibility traits of the element to wait for. Elements that do not include at least these traits are ignored.
*/
func waitForFirstResponder(withAccessibilityLabel label: String!, traits: UIAccessibilityTraits)
func tapStatusBar()
/*!
@abstract Scrolls a table view with the given identifier while waiting for the cell at the given indexPath to appear.
@discussion This step will get the view with the specified accessibility identifier and then get the cell at the indexPath.
By default, scrolls to the middle of the cell. If you need to scroll to top/bottom, use the @c atPosition: variation.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the cell.
@param identifier Accessibility identifier of the table view.
@result Table view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, inTableViewWithAccessibilityIdentifier identifier: String!) -> UITableViewCell!
/*!
@abstract Scrolls a table view with the given identifier while waiting for the cell at the given indexPath to appear.
@discussion This step will get the view with the specified accessibility identifier and then get the cell at the indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the cell.
@param identifier Accessibility identifier of the table view.
@param position Table View scroll position to scroll to. Useful for tall cells when the content needed is in a specific location.
@result Table view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, inTableViewWithAccessibilityIdentifier identifier: String!, at position: UITableViewScrollPosition) -> UITableViewCell!
/*!
@abstract Scrolls a table view while waiting for the cell at the given indexPath to appear.
@discussion This step will get the cell at the indexPath.
By default, scrolls to the middle of the cell. If you need to scroll to top/bottom, use the @c atPosition: variation.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the cell.
@param tableView UITableView containing the cell.
@result Table view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, in tableView: UITableView!) -> UITableViewCell!
/*!
@abstract Scrolls a table view while waiting for the cell at the given indexPath to appear.
@discussion This step will get the cell at the indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the cell.
@param tableView UITableView containing the cell.
@param position Table View scroll position to scroll to. Useful for tall cells when the content needed is in a specific location.
@result Table view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, in tableView: UITableView!, at position: UITableViewScrollPosition) -> UITableViewCell!
/*!
@abstract Scrolls a collection view while waiting for the cell at the given indexPath to appear.
@discussion This step will get the cell at the indexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param indexPath Index path of the cell.
@param collectionView UICollectionView containing the cell.
@result Collection view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, in collectionView: UICollectionView!) -> UICollectionViewCell!
/*!
@abstract Scrolls a given collection view while waiting for the item at the given indexPath to appear.
@discussion This step will get the view with the specified accessibility identifier and then get the cell at indexPath.
For cases where you may need to work from the end of a collection view rather than the beginning, negative sections count back from the end of the collection view (-1 is the last section) and negative items count back from the end of the section (-1 is the last item for that section).
@param indexPath Index path of the item to tap.
@param identifier Accessibility identifier of the collection view.
@result Collection view cell at index path
*/
func waitForCell(at indexPath: IndexPath!, inCollectionViewWithAccessibilityIdentifier identifier: String!) -> UICollectionViewCell!
/*!
@abstract Moves the row at sourceIndexPath to destinationIndexPath in a table view with the given identifier.
@discussion This step will get the view with the specified accessibility identifier and move the row at sourceIndexPath to destinationIndexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param sourceIndexPath Index path of the row to move.
@param destinationIndexPath Desired final index path of the row after moving.
@param identifier Accessibility identifier of the table view.
*/
func moveRow(at sourceIndexPath: IndexPath!, to destinationIndexPath: IndexPath!, inTableViewWithAccessibilityIdentifier identifier: String!)
/*!
@abstract Moves the row at sourceIndexPath to destinationIndexPath in a given table view.
@discussion This step will move the row at sourceIndexPath to destinationIndexPath.
For cases where you may need to work from the end of a table view rather than the beginning, negative sections count back from the end of the table view (-1 is the last section) and negative rows count back from the end of the section (-1 is the last row for that section).
@param sourceIndexPath Index path of the row to move.
@param destinationIndexPath Desired final index path of the row after moving.
@param tableView UITableView containing the cell.
*/
func moveRow(at sourceIndexPath: IndexPath!, to destinationIndexPath: IndexPath!, in tableView: UITableView!)
/*!
@abstract Swipes the row at indexPath in the given direction.
@param indexPath Index path of the row to swipe.
@param tableView Table view to operate on.
@param direction Direction of the swipe.
*/
func swipeRow(at indexPath: IndexPath!, in tableView: UITableView!, in direction: KIFSwipeDirection)
/*!
@abstract Waits for the given cell to transition to the delete state. Useful when swiping left on a cell for delete action.
@param cell Cell to wait for delete state on.
*/
func waitForDeleteState(for cell: UITableViewCell!)
/*!
@abstract Waits for the given cell to transition to the delete state. Useful when swiping left on a cell for delete action.
@param indexPath Index path of the row to wait for the delete state on.
@param tableView Table view to operate on.
*/
func waitForDeleteStateForCell(at indexPath: IndexPath!, in tableView: UITableView!)
/*!
@abstract Backgrounds app using UIAutomation command, simulating pressing the Home button
@param duration Amount of time for a background event before the app becomes active again
*/
@available(*, deprecated, message: "Use [system deactivateAppForDuration:] instead.")
func deactivateApp(forDuration duration: TimeInterval)
}
extension XCTestCase {
func tester(file : String = #file, _ line : Int = #line) -> TestActor {
return KIFUITestActor(inFile: file, atLine: line, delegate: self)
}
func system(file : String = #file, _ line : Int = #line) -> SystemTestActor {
return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
}
}
extension KIFTestActor {
func tester(file : String = #file, _ line : Int = #line) -> TestActor {
return KIFUITestActor(inFile: file, atLine: line, delegate: self)
}
func system(file : String = #file, _ line : Int = #line) -> SystemTestActor {
return KIFSystemTestActor(inFile: file, atLine: line, delegate: self)
}
}
extension KIFUITestActor: TestActor {}
extension KIFSystemTestActor: SystemTestActor {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment