UNPKG

appium-xcuitest-driver

Version:

Appium driver for iOS using XCUITest for backend

286 lines 19.3 kB
/** * * @param {any[]} gestures * @param {string[]|null} keysToInclude * @returns {string} */ export function gesturesChainToString(gestures: any[], keysToInclude?: string[] | null): string; declare namespace _default { /** * Shake the device * @this {XCUITestDriver} * @group Simulator Only */ function mobileShake(this: import("../driver").XCUITestDriver): Promise<void>; /** * @this {XCUITestDriver} */ function click(this: import("../driver").XCUITestDriver, el: any): Promise<any>; /** * @this {XCUITestDriver} */ function releaseActions(this: import("../driver").XCUITestDriver): Promise<void>; /** * @param {import('@appium/types').ActionSequence[]} actions * @returns {Promise<void>} * @this {XCUITestDriver} */ function performActions(this: import("../driver").XCUITestDriver, actions: import("@appium/types").ActionSequence[]): Promise<void>; /** * @param {import('@appium/types').Element|string} el * @this {XCUITestDriver} * @group Native Only */ function nativeClick(this: import("../driver").XCUITestDriver, el: import("@appium/types").Element | string): Promise<unknown>; /** * Scrolls the current viewport to the given element. * * This command expects the destination element to be inside a scrollable container and is hittable. The scroll direction is detected automatically. * * This API uses native XCTest calls, so it is performant. The same native call is implicitly performed by a `click` command if the destination element is outside the current viewport. * * @since 4.7.0 * @throws If the scrolling action cannot be performed * @privateRemarks See https://github.com/facebook/WebDriverAgent/blob/master/WebDriverAgentLib/Commands/FBElementCommands.m for details on WDA gestures API * @param {Element|string} elementId - The internal element identifier (as hexadecimal hash string) to scroll to. The destination element must be located in a scrollable container and must be hittable. If the element is already present in the current viewport then no action is performed. * @returns {Promise<void>} * @this {XCUITestDriver} */ function mobileScrollToElement(this: import("../driver").XCUITestDriver, elementId: Element | string): Promise<void>; /** * Scrolls an element or the entire screen. * * Use this command to emulate precise scrolling in tables or collection views where it is already known to which element the scrolling should be performed. * * The arguments define the choosen strategy: one of `name`, `direction`, `predicateString` or `toVisible`. * * **All strategies are exclusive**; only one strategy can be used at one time. * * **Known Limitations:** * * - If it is necessary to perform many scroll gestures on parent container to reach the necessary child element (tens of them), then the method call may fail. * * - The implemntation of this extension relies on several undocumented XCTest features, which might not always be reliable. * * @param {string} [name] - The internal element identifier (as hexadecimal hash string) to scroll on (e.g. the container). The Application element will be used if this argument is not provided. * @param {import('./types').Direction} [direction] - The main difference between this command and a `mobile: swipe` command using the same direction is that `mobile: scroll` will attempt to move the current viewport exactly to the next or previous page (the term "page" means the content, which fits into a single device screen). * @param {string} [predicateString] - The `NSPredicate` locator of the child element, to which the scrolling should be performed. Has no effect if `elementId` is not a container. * @param {boolean} [toVisible] - If `true`, scrolls to the first visible `elementId` in the parent container. Has no effect if `elementId` is unset. * @param {number} [distance] - A ratio of the screen height; `1.0` means a full-screen-worth of scrolling. * @param {Element|string} [elementId] - Element ID or Element used in various strategies. * @returns {Promise<void>} * @this {XCUITestDriver} * @example * ```python * driver.execute_script('mobile: scroll', {'direction': 'down'}) * ``` */ function mobileScroll(this: import("../driver").XCUITestDriver, name?: string, direction?: import("./types").Direction, predicateString?: string, toVisible?: boolean, distance?: number, elementId?: Element | string): Promise<void>; /** * @param {import('./types').Direction} direction * @param {number} [velocity] * @param {Element|string} [elementId] * @this {XCUITestDriver} */ function mobileSwipe(this: import("../driver").XCUITestDriver, direction: import("./types").Direction, velocity?: number, elementId?: Element | string): Promise<void>; /** * Performs a pinch gesture on the given element or on the Application element. * * @param {number} scale - Pinch scale (float value). A value between `0` and `1` performs a "pinch close" (or "zoom out"); a value greater than `1` performs a "pinch open" ("zoom in"). * @param {number} velocity - The velocity of the pinch in scale factor per second (float value). * @param {Element|string} [elementId] The internal element identifier (as hexadecimal hash string) to pinch on. The Application element will be used if this parameter is not provided. * @returns {Promise<void>} * @this {XCUITestDriver} * @see https://developer.apple.com/documentation/xctest/xcuielement/1618669-pinchwithscale?language=objc * @example * * ```ruby * execute_script 'mobile: pinch', scale: 0.5, velocity: 1.1, element: element.ref * ``` */ function mobilePinch(this: import("../driver").XCUITestDriver, scale: number, velocity: number, elementId?: Element | string): Promise<void>; /** * Performs double tap gesture on the given element or on the screen. * * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. The Application element will be used if this parameter is not provided. * @param {number} [x] - The _x_ coordinate (float value) to double tap on. * @param {number} [y] - The _y_ coordinate (float value) to double tap on. * @returns {Promise<void>} * @this {XCUITestDriver} * @example * ```javascript * // using WebdriverIO * await driver.execute('mobile: doubleTap', {element: element.value.ELEMENT}); * ``` */ function mobileDoubleTap(this: import("../driver").XCUITestDriver, elementId?: Element | string, x?: number, y?: number): Promise<void>; /** * Performs two finger tap gesture on the given element or on the application element. * * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. The Application element will be used if this parameter is not provided. * @returns {Promise<void>} * @this {XCUITestDriver} * @see https://developer.apple.com/documentation/xctest/xcuielement/1618675-twofingertap?language=objc * @example * ```csharp * Dictionary<string, object> tfTap = new Dictionary<string, object>(); * tfTap.Add("element", element.Id); * ((IJavaScriptExecutor)driver).ExecuteScript("mobile: twoFingerTap", tfTap); * ``` */ function mobileTwoFingerTap(this: import("../driver").XCUITestDriver, elementId?: Element | string): Promise<void>; /** * Performs a "long press" gesture on the given element or on the screen. * * @param {number} duration - The duration (in seconds) of the gesture. * @param {number} [y] - The _y_ coordinate (float value) to hold on. * @param {number} [x] - The _x_ coordinate (float value) to hold on. * @param {Element|string} [elementId] - The internal element identifier (as hexadecimal hash string) to double tap on. The Application element will be used if this parameter is not provided. * @this {XCUITestDriver} * @see https://developer.apple.com/documentation/xctest/xcuielement/1618663-pressforduration?language=objc * @example * ```csharp * Dictionary<string, object> tfLongTap = new Dictionary<string, object>(); * tfLongTap.Add("element", element.Id); * tfLongTap.Add("duration", 2.0); * ((IJavaScriptExecutor)driver).ExecuteScript("mobile: touchAndHold", tfLongTap); * ``` */ function mobileTouchAndHold(this: import("../driver").XCUITestDriver, duration: number, x?: number, y?: number, elementId?: Element | string): Promise<void>; /** * Performs tap gesture by coordinates on the given element or on the screen. * * @param {number} x - The _x_ coordinate (float value) to tap on. If `elementId` is provided, this is computed relative to the element; otherwise it is computed relative to the active Application element. * @param {number} y - The _y_ coordinate (float value) to tap on. If `elementId` is provided, this is computed relative to the element; otherwise it is computed relative to the active Application element. * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to tap on. The Application element will be used if this parameter is not provided. * @this {XCUITestDriver} * @returns {Promise<void>} */ function mobileTap(this: import("../driver").XCUITestDriver, x: number, y: number, elementId?: string | Element): Promise<void>; /** * Performs drag and drop gesture by coordinates on the given element or on the screen. * * @param {number} duration - The duration (in seconds) of the gesture. Must be between `0.5` and `60.0`, inclusive. * @param {number} fromX - The _x_ coordinate (float value) of the starting drag point. * @param {number} fromY - The _y_ coordinate (float value) of the starting drag point. * @param {number} toX - The _x_ coordinate (float value) of the ending drag point. * @param {number} toY - The _y_ coordinate (float value) of the ending drag point. * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to drag. If provided, all coordinates will be calculated relative to this element; otherwise they will be calculated relative to the active Application element. * @returns {Promise<void>} * @see https://developer.apple.com/documentation/xctest/xcuielement/1500989-clickforduration?language=objc * @this {XCUITestDriver} * @example * ```java * JavascriptExecutor js = (JavascriptExecutor) driver; * Map<String, Object> params = new HashMap<>(); * params.put("duration", 1.0); * params.put("fromX", 100); * params.put("fromY", 100); * params.put("toX", 200); * params.put("toY", 200); * params.put("element", ((RemoteWebElement) element).getId()); * js.executeScript("mobile: dragFromToForDuration", params); * ``` */ function mobileDragFromToForDuration(this: import("../driver").XCUITestDriver, duration: number, fromX: number, fromY: number, toX: number, toY: number, elementId?: string | Element): Promise<void>; /** * Initiates a press-and-hold gesture, drags to another coordinate or an element with a given velocity, and holds for a given duration. * * @param {number} pressDuration - The duration (in seconds) of the press-and-hold gesture at the starting point. Must be between `0.5` and `60.0`, inclusive. * @param {number} holdDuration - The duration (in seconds) of the hold gesture at the ending point (after dragging). Must be between `0.5` and `60.0`, inclusive. * @param {number} velocity - The speed (in pixels-per-second) which to move from the initial position to the end position. * @param {string|Element} [fromElementId] - The internal element identifier (as hexadecimal hash string) to drag from. Absolute screen coordinates are expected if this argument is not provided. * @param {string|Element} [toElementId] - The internal element identifier (as hexadecimal hash string) to drag to. Absolute screen coordinates are expected if this argument is not provided. * @param {number} [fromX] - The _x_ coordinate (float value) of the starting drag point. * @param {number} [fromY] - The _y_ coordinate (float value) of the starting drag point. * @param {number} [toX] - The _x_ coordinate (float value) of the ending drag point. * @param {number} [toY] - The _y_ coordinate (float value) of the ending drag point. * @returns {Promise<void>} * @see https://developer.apple.com/documentation/xctest/xcuielement/3551693-pressforduration?language=objc * @see https://developer.apple.com/documentation/xctest/xcuicoordinate/3551692-pressforduration?language=objc * @this {XCUITestDriver} */ function mobileDragFromToWithVelocity(this: import("../driver").XCUITestDriver, pressDuration: number, holdDuration: number, velocity: number, fromElementId?: string | Element, toElementId?: string | Element, fromX?: number, fromY?: number, toX?: number, toY?: number): Promise<void>; /** * Sends one or more taps with one or more touch points. * * @since 1.17.1 * @param {number} [numberOfTaps=1] - Number of taps to perform. * @param {number} [numberOfTouches=1] - Number of touch points to use. * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform one or more taps. * The Application element will be used if this parameter is not provided. * @returns {Promise<void>} * @this {XCUITestDriver} * @see https://developer.apple.com/documentation/xctest/xcuielement/1618671-tapwithnumberoftaps?language=objc * @example * ```ruby * e = @driver.find_element :id, 'target element' * # Taps the element with a single touch point twice * @driver.execute_script 'mobile: tapWithNumberOfTaps', {element: e.ref, numberOfTaps: 2, numberOfTouches: 1} * ``` */ function mobileTapWithNumberOfTaps(this: import("../driver").XCUITestDriver, numberOfTouches?: number, numberOfTaps?: number, elementId?: string | Element): Promise<void>; /** * Performs a "force press" on the given element or coordinates. * * @throws If the target device does not support the "force press" gesture. * @param {number} [x] - The _x_ coordinate of the gesture. If `elementId` is set, this is calculated relative to its position; otherwise it's calculated relative to the active Application. * @param {number} [y] - The _y_ coordinate of the gesture. If `elementId` is set, this is calculated relative to its position; otherwise it's calculated relative to the active Application. * @param {number} [duration] - The duraiton (in seconds) of the force press. If this is provided, `pressure` must also be provided. * @param {number} [pressure] - A float value defining the pressure of the force press. If this is provided, `duration` must also be provided. * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform one or more taps. * The Application element will be used if this parameter is not provided. * @returns {Promise<void>} * @this {XCUITestDriver} */ function mobileForcePress(this: import("../driver").XCUITestDriver, x?: number, y?: number, duration?: number, pressure?: number, elementId?: string | Element): Promise<void>; /** * Performs selection of the next or previous picker wheel value. * * This might be useful if these values are populated dynamically; you don't know which one to select, or the value selection using the `sendKeys` API does not work (for whatever reason). * * @throws Upon failure to change the current picker value. * @param {string|Element} elementId - `PickerWheel`'s internal element ID as hexadecimal hash string. Value selection will be performed on this element. This element must be of type `XCUIElementTypePickerWheel`. * @param {'next'|'previous'} order - Either `next` to select the value _next_ to the current from the target picker wheel, or `previous` to select the _previous_ value. * @param {number} [offset=0.2] - The value in range `[0.01, 0.5]`. It defines how far from picker wheel's center the click should happen. The actual distance is calculated by multiplying this value to the actual picker wheel height. Too small an offset value may not change the picker wheel value at all, and too high a value may cause the wheel to switch two or more values at once. Usually the optimal value is located in range `[0.15, 0.3]`. * @param {string?} [value=undefined] - If provided WDA will try to automatically scroll in the given direction until the actual picker value reaches the expected one or the amount of scrolling attempts is exceeded. * @param {number} [maxAttempts=25] - The maximum number of scrolling attempts to reach `value` before an error will be thrown. Only makes sense in combination with `value`. * @this {XCUITestDriver} * @example * ```java * JavascriptExecutor js = (JavascriptExecutor) driver; * Map<String, Object> params = new HashMap<>(); * params.put("order", "next"); * params.put("offset", 0.15); * params.put("element", ((RemoteWebElement) element).getId()); * js.executeScript("mobile: selectPickerWheelValue", params); * ``` */ function mobileSelectPickerWheelValue(this: import("../driver").XCUITestDriver, elementId: string | Element, order: "next" | "previous", offset?: number, value?: string | null, maxAttempts?: number): Promise<unknown>; /** * Performs a rotate gesture on the given element. * * @see https://developer.apple.com/documentation/xctest/xcuielement/1618665-rotate?language=objc * @param {number} rotation - The rotation gesture (in radians) * @param {number} velocity - The velocity (in radians-per-second) of the gesture. * @param {string|Element} [elementId] - The internal element identifier (as hexadecimal hash string) to perform the gesture on. * The Application element will be used if this parameter is not provided. * @returns {Promise<void>} * @this {XCUITestDriver} * @example * ```java * JavascriptExecutor js = (JavascriptExecutor) driver; * js.executeScript("mobile: rotateElement", ImmutableMap.of( * // rotate clockwise, 90 degrees * "rotation", -Math.PI / 2, * // in approximately two seconds * "velocity", Math.PI / 4, * "element", ((RemoteWebElement) element).getId() * )); * ``` */ function mobileRotateElement(this: import("../driver").XCUITestDriver, rotation: number, velocity: number, elementId?: string | Element): Promise<void>; } export default _default; export type XCUITestDriver = import("../driver").XCUITestDriver; export type Element = import("@appium/types").Element; //# sourceMappingURL=gesture.d.ts.map