Skip to content

Commit f35d3e2

Browse files
feat: implement pinch, pan, rotate and scroll
Still in experimental mode
1 parent 3eb2e70 commit f35d3e2

File tree

5 files changed

+309
-142
lines changed

5 files changed

+309
-142
lines changed

lib/appium-driver.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ export class AppiumDriver {
482482
* @param xOffset
483483
*/
484484
public async scroll(direction: Direction, y: number, x: number, yOffset: number, xOffset: number = 0) {
485-
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset, this._args.verbose);
485+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset);
486486
}
487487

488488
/**
@@ -502,7 +502,7 @@ export class AppiumDriver {
502502
el = await element();
503503
isDisplayed = await el.isDisplayed();
504504
if (!isDisplayed) {
505-
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y, this._args.verbose);
505+
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y);
506506
el = null;
507507
}
508508
} catch (error) {

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
*/
@@ -164,5 +166,51 @@ export declare class UIElement {
164166
* Swipe element left/right
165167
* @param direction
166168
*/
167-
swipe(direction: Direction): Promise<void>;
169+
swipe(direction: "up" | "down" | "left" | "right"): Promise<void>;
170+
/**
171+
* Drag element with specific offset
172+
* @experimental
173+
* @param direction
174+
* @param yOffset
175+
* @param xOffset - default value 0
176+
*/
177+
drag(direction: Direction, yOffset: number, xOffset?: number): Promise<void>;
178+
/**
179+
*@experimental
180+
* Pan element with specific offset
181+
* @param points where the finger should move to.
182+
* @param initPointOffset element.getRectangle() is used as start point. In case some additional offset should be provided use this param.
183+
*/
184+
pan(points: {
185+
x: number;
186+
y: number;
187+
}[], initPointOffset?: {
188+
x: number;
189+
y: number;
190+
}): Promise<void>;
191+
/**
192+
* @experimental
193+
* This method will try to move two fingers from opposite corners.
194+
* One finger starts from
195+
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
196+
* and ends to
197+
* { x: elementRect.x + elementRect.width - offset.x, y: elementRect.height + elementRect.y - offset.y }
198+
* and the other finger starts from
199+
* { x: elementRect.width + elementRect.x - offset.x, y: elementRect.height + elementRect.y - offset.y }
200+
* and ends to
201+
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
202+
*/
203+
rotate(offset?: {
204+
x: number;
205+
y: number;
206+
}): Promise<void>;
207+
/**
208+
* @experimental
209+
* @param zoomFactory - zoomIn or zoomOut. Only zoomIn action is implemented
210+
* @param offset
211+
*/
212+
pinch(zoomType: "in" | "out", offset?: {
213+
x: number;
214+
y: number;
215+
}): Promise<void>;
168216
}

0 commit comments

Comments
 (0)