انتقل إلى المحتوى
CloudClick iOS

Gestures & keys

Taps, swipes, drags and pinches, plus hardware buttons and the keyboard. Coordinates can be points or 0–1 screen ratios; directional swipes re-randomise the start point, distance, angle and duration every time and follow a hand-like path.

نظرة عامة

  • ·The swipe family uses the W3C channel with human-like paths; the drag family uses WDA's native channel for better compatibility
  • ·Directional swipes avoid the screen edges by default; pass 'edge' when you want a system edge gesture such as swipe-back
  • ·Every duration is in seconds

client.click#

Tap at a coordinate; with a duration it holds for that many seconds before releasing (a long press).

typescript
client.click(x: number, y: number, duration?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
xnumberنعم—Horizontal position: a 0–1 screen ratio, or points.
ynumberنعم—Vertical position: a 0–1 screen ratio, or points.
durationnumberلا—Seconds to hold. Omit for a plain tap.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorRatio coordinates were given but the screen size could not be read (the WDA session is unhealthy).

ملاحظات

  • When x and y both fall between 0 and 1 they are screen ratios (0.5, 0.5 is the centre); otherwise they are points. The conversion needs the screen size and throws if it cannot be read.

مثال

javascript
client.click(0.5, 0.5);        // 屏幕正中 / screen centre
client.click(200, 640);        // point
client.click(0.5, 0.9, 1.2);   // 长按 1.2 秒 / long press

انظر أيضًا client.tapHold、element.click

client.swipe#

Swipe from (x1, y1) to (x2, y2). The end points are exact; the path between them is hand-like — a slight random curve, slow then fast, with small jitter.

typescript
client.swipe(x1: number, y1: number, x2: number, y2: number, durationSec?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
x1numberنعم—Start x.
y1numberنعم—Start y.
x2numberنعم—End x.
y2numberنعم—End y.
durationSecnumberلا0Seconds from the start of the movement to lift-off. 0 picks a random duration based on the distance.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorRatio coordinates were given but the screen size could not be read (the WDA session is unhealthy).

ملاحظات

  • When x and y both fall between 0 and 1 they are screen ratios (0.5, 0.5 is the centre); otherwise they are points. The conversion needs the screen size and throws if it cannot be read.

مثال

javascript
client.swipe(0.5, 0.8, 0.5, 0.2);        // 往上滑 / swipe up
client.swipe(0.5, 0.8, 0.5, 0.2, 0.6);   // 指定 0.6 秒 / take 0.6 seconds

انظر أيضًا client.swipeUp、client.drag

client.drag#

A native WDA drag from (x1, y1) to (x2, y2). The system generates the path and speed; in some apps (custom-drawn views, older iOS) it is more reliable than swipe.

typescript
client.drag(x1: number, y1: number, x2: number, y2: number, durationSec?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
x1numberنعم—Start x.
y1numberنعم—Start y.
x2numberنعم—End x.
y2numberنعم—End y.
durationSecnumberلا0Seconds to hold the start point before dragging — not the duration of the drag itself. 0 drags immediately.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorRatio coordinates were given but the screen size could not be read (the WDA session is unhealthy).

ملاحظات

  • When x and y both fall between 0 and 1 they are screen ratios (0.5, 0.5 is the centre); otherwise they are points. The conversion needs the screen size and throws if it cannot be read.

مثال

javascript
client.drag(0.2, 0.5, 0.8, 0.5, 0.3);

انظر أيضًا client.swipe、client.dragUp

client.swipeUp#

Move the finger up (content moves up, revealing what is below). The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses the W3C gesture channel with a hand-like path: a slight random curve, slow then fast, with small jitter.

typescript
client.swipeUp(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the bottom edge, which is the system's go-home gesture — rarely what you want.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

ملاحظات

  • For the short, quick swipe from the lower screen used to scroll a feed, call client.swipeUpFromBottom(); swipeDownFromBottom, dragUpFromBottom and dragDownFromBottom are also available.

مثال

javascript
client.swipeUp();

انظر أيضًا client.swipe

client.swipeDown#

Move the finger down (content moves down, revealing what is above). The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses the W3C gesture channel with a hand-like path: a slight random curve, slow then fast, with small jitter.

typescript
client.swipeDown(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the top edge, which pulls down Notification Centre.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.swipeDown();

انظر أيضًا client.swipe

client.swipeLeft#

Move the finger from right to left. The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses the W3C gesture channel with a hand-like path: a slight random curve, slow then fast, with small jitter.

typescript
client.swipeLeft(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the right edge.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.swipeLeft();

انظر أيضًا client.swipe

client.swipeRight#

Move the finger from left to right. The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses the W3C gesture channel with a hand-like path: a slight random curve, slow then fast, with small jitter.

typescript
client.swipeRight(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the left edge, which is the system's swipe-back gesture.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.swipeRight();          // 普通右滑 / a normal swipe
client.swipeRight('edge');    // 返回上一页 / go back

انظر أيضًا client.swipe

client.dragUp#

Move the finger up (content moves up). The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses WDA's native drag channel and holds the start point for a random 0.05–0.2 seconds before moving. Switch to this family when swipe has no effect in an app.

typescript
client.dragUp(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the bottom edge.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.dragUp();

انظر أيضًا client.drag

client.dragDown#

Move the finger down (content moves down). The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses WDA's native drag channel and holds the start point for a random 0.05–0.2 seconds before moving. Switch to this family when swipe has no effect in an app.

typescript
client.dragDown(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the top edge.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.dragDown();

انظر أيضًا client.drag

client.dragLeft#

Move the finger from right to left. The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses WDA's native drag channel and holds the start point for a random 0.05–0.2 seconds before moving. Switch to this family when swipe has no effect in an app.

typescript
client.dragLeft(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the right edge.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.dragLeft();

انظر أيضًا client.drag

client.dragRight#

Move the finger from left to right. The start point, distance (35–55% of the screen), angle (±5°) and duration are randomised every time, and by default the gesture stays at least 8% away from the screen edges so it never triggers a system edge gesture. Uses WDA's native drag channel and holds the start point for a random 0.05–0.2 seconds before moving. Switch to this family when swipe has no effect in an app.

typescript
client.dragRight(from?: "edge"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
from"edge"لا—Omit it for a normal swipe; pass 'edge' to start at the screen edge: starts at the left edge.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorINVALID_ARGUMENTThe argument is neither omitted nor 'edge' (for example an old-style { fromEdge: true }).

مثال

javascript
client.dragRight();

انظر أيضًا client.drag

client.scroll#

Let WDA scroll the current screen in a direction. XCUITest computes the amount, which makes it more reliable than a swipe for lists and other scroll views.

typescript
client.scroll(direction: "up" | "down" | "left" | "right", distance?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
direction"up" | "down" | "left" | "right"نعم—The direction to scroll.
distancenumberلا1.0How far to scroll; 1.0 is roughly one screen.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

مثال

javascript
client.scroll('down', 1.0);

انظر أيضًا client.swipeUp

client.pinch#

A two-finger pinch: a scale above 1 spreads the fingers (zoom in), below 1 pinches them together (zoom out).

typescript
client.pinch(scale: number, velocity?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
scalenumberنعم—The scale factor.
velocitynumberلا1The speed; pass a negative value when pinching in (scale below 1).

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

مثال

javascript
client.pinch(2, 1);      // 放大 / zoom in
client.pinch(0.5, -1);   // 缩小 / zoom out

client.hideKeyboard#

Dismiss the keyboard; client.isKeyboardShown() tells whether it is up.

typescript
client.hideKeyboard(): boolean;
client.isKeyboardShown(): boolean;

القيمة المُعادة

النوعالوصف
booleanhideKeyboard: true once the keyboard is gone (also when it was never up); isKeyboardShown: true while the keyboard is visible.

مثال

javascript
if (client.isKeyboardShown()) {
  client.hideKeyboard();
}

انظر أيضًا client.sendKeys

client.tapHold#

Press and hold at a point, then release (a long press).

typescript
client.tapHold(x: number, y: number, duration?: number): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
xnumberنعم—Horizontal position: a 0–1 screen ratio, or points.
ynumberنعم—Vertical position: a 0–1 screen ratio, or points.
durationnumberلا1.0Seconds to hold.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
WDAErrorRatio coordinates were given but the screen size could not be read (the WDA session is unhealthy).

ملاحظات

  • When x and y both fall between 0 and 1 they are screen ratios (0.5, 0.5 is the centre); otherwise they are points. The conversion needs the screen size and throws if it cannot be read.

مثال

javascript
client.tapHold(0.5, 0.5, 1.5);

انظر أيضًا client.click

client.home#

Go to the Home Screen.

typescript
client.home(): void;

مثال

javascript
client.home();

انظر أيضًا client.press

client.press#

Press a hardware button: home, volumeUp or volumeDown.

typescript
client.press(name: "home" | "volumeUp" | "volumeDown"): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
name"home" | "volumeUp" | "volumeDown"نعم—The button name.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

الاستثناءات

الاستثناءمتى يحدث
ErrorThe name is not one of the three.

مثال

javascript
client.press('volumeUp');

انظر أيضًا client.home

client.sendKeys#

Type into the focused text field, character by character through the keyboard. Tap the field first so it has focus.

typescript
client.sendKeys(value: string): object;

المعاملات

الاسمالنوعمطلوبالقيمة الافتراضيةالوصف
valuestringنعم—The text to type; non-ASCII text is supported.

القيمة المُعادة

النوعالوصف
objectThe raw WDA response; rarely needed.

مثال

javascript
clickElement('accessibilityId', 'search_field', 5);
client.sendKeys('hello');

انظر أيضًا client.hideKeyboard、client.setClipboard

client.lock#

Lock the screen; client.unlock() unlocks it and client.locked() tells whether it is locked.

typescript
client.lock(): object;
client.unlock(): object;
client.locked(): boolean;

القيمة المُعادة

النوعالوصف
object | booleanlock / unlock return the raw WDA response; locked returns true while the screen is locked.

ملاحظات

  • Unlocking only works on devices without a passcode.

مثال

javascript
if (client.locked()) {
  client.unlock();
}