Skip to content

Commit 2099bfe

Browse files
feat: implement pinch, pan, rotate and scroll
Still in experimental mode
1 parent 21cdc41 commit 2099bfe

8 files changed

+312
-145
lines changed

lib/appium-driver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export class AppiumDriver {
467467
* @param xOffset
468468
*/
469469
public async scroll(direction: Direction, y: number, x: number, yOffset: number, xOffset: number = 0) {
470-
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset, this._args.verbose);
470+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset);
471471
}
472472

473473
/**
@@ -487,7 +487,7 @@ export class AppiumDriver {
487487
el = await element();
488488
isDisplayed = await el.isDisplayed();
489489
if (!isDisplayed) {
490-
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y, this._args.verbose);
490+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y);
491491
el = null;
492492
}
493493
} catch (error) {

lib/device-manager.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare class DeviceManager implements IDeviceManager {
1313
static getInstalledApps(device: IDevice): Promise<string[]>;
1414
static getDefaultDevice(args: INsCapabilities, deviceName?: string, token?: string, type?: DeviceType, platformVersion?: number): IDevice;
1515
private static convertViewportRectToIRectangle;
16-
static applyAppiumSessionInfoDetails(args: INsCapabilities, sessionInfoDetails: any): IDevice;
16+
static applyAppiumSessionInfoDetails(args: INsCapabilities, sessionInfoDetails: any): any;
1717
static setDontKeepActivities(args: INsCapabilities, driver: any, value: any): Promise<void>;
1818
static executeShellCommand(driver: any, commandArgs: {
1919
command: string;

lib/parser.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { LogImageType } from "./enums/log-image-type";
2-
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: import("mobile-devices-controller/lib/device").IDevice, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;
2+
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: any, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;

lib/ui-element.d.ts

+57-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export declare class UIElement {
1616
* Click on element
1717
*/
1818
click(): Promise<any>;
19+
getCenter(): Promise<{
20+
x: number;
21+
y: number;
22+
}>;
1923
tapCenter(): Promise<void>;
2024
tapAtTheEnd(): Promise<void>;
2125
/**
@@ -26,17 +30,22 @@ export declare class UIElement {
2630
*/
2731
tap(): Promise<any>;
2832
/**
33+
* @experimental
2934
* Double tap on element
3035
*/
3136
doubleTap(): Promise<any>;
37+
longPress(duration: number): Promise<void>;
3238
/**
3339
* Get location of element
3440
*/
3541
location(): Promise<Point>;
3642
/**
3743
* Get size of element
3844
*/
39-
size(): Promise<Point>;
45+
size(): Promise<{
46+
width: number;
47+
height: number;
48+
}>;
4049
/**
4150
* Get text of element
4251
*/
@@ -113,13 +122,6 @@ export declare class UIElement {
113122
*/
114123
scrollTo(direction: Direction, elementToSearch: () => Promise<UIElement>, yOffset?: number, xOffset?: number, retries?: number): Promise<UIElement>;
115124
/**
116-
* Drag element with specific offset
117-
* @param direction
118-
* @param yOffset
119-
* @param xOffset - default value 0
120-
*/
121-
drag(direction: Direction, yOffset: number, xOffset?: number): Promise<void>;
122-
/**
123125
* Click and hold over an element
124126
* @param time in milliseconds to increase the default press period.
125127
*/
@@ -161,5 +163,51 @@ export declare class UIElement {
161163
* Swipe element left/right
162164
* @param direction
163165
*/
164-
swipe(direction: Direction): Promise<void>;
166+
swipe(direction: "up" | "down" | "left" | "right"): Promise<void>;
167+
/**
168+
* Drag element with specific offset
169+
* @experimental
170+
* @param direction
171+
* @param yOffset
172+
* @param xOffset - default value 0
173+
*/
174+
drag(direction: Direction, yOffset: number, xOffset?: number): Promise<void>;
175+
/**
176+
*@experimental
177+
* Pan element with specific offset
178+
* @param points where the finger should move to.
179+
* @param initPointOffset element.getRectangle() is used as start point. In case some additional offset should be provided use this param.
180+
*/
181+
pan(points: {
182+
x: number;
183+
y: number;
184+
}[], initPointOffset?: {
185+
x: number;
186+
y: number;
187+
}): Promise<void>;
188+
/**
189+
* @experimental
190+
* This method will try to move two fingers from opposite corners.
191+
* One finger starts from
192+
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
193+
* and ends to
194+
* { x: elementRect.x + elementRect.width - offset.x, y: elementRect.height + elementRect.y - offset.y }
195+
* and the other finger starts from
196+
* { x: elementRect.width + elementRect.x - offset.x, y: elementRect.height + elementRect.y - offset.y }
197+
* and ends to
198+
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
199+
*/
200+
rotate(offset?: {
201+
x: number;
202+
y: number;
203+
}): Promise<void>;
204+
/**
205+
* @experimental
206+
* @param zoomFactory - zoomIn or zoomOut. Only zoomIn action is implemented
207+
* @param offset
208+
*/
209+
pinch(zoomType: "in" | "out", offset?: {
210+
x: number;
211+
y: number;
212+
}): Promise<void>;
165213
}

0 commit comments

Comments
 (0)