Skip to content

feat: implement pinch, pan, rotate and scroll #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/appium-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class AppiumDriver {
* @param xOffset
*/
public async scroll(direction: Direction, y: number, x: number, yOffset: number, xOffset: number = 0) {
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset, this._args.verbose);
await scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset);
}

/**
Expand All @@ -505,7 +505,7 @@ export class AppiumDriver {
el = await element();
isDisplayed = await el.isDisplayed();
if (!isDisplayed) {
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y, this._args.verbose);
await scroll(this._wd, this._driver, direction, this._webio.isIOS, startPoint.y, startPoint.x, offsetPoint.x, offsetPoint.y);
el = null;
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/direction.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare const enum Direction {
export declare enum Direction {
down = 0,
up = 1,
left = 2,
Expand Down
2 changes: 1 addition & 1 deletion lib/direction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const enum Direction {
export enum Direction {
down,
up,
left,
Expand Down
64 changes: 56 additions & 8 deletions lib/ui-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export declare class UIElement {
* Click on element
*/
click(): Promise<any>;
getCenter(): Promise<{
x: number;
y: number;
}>;
tapCenter(): Promise<void>;
tapAtTheEnd(): Promise<void>;
/**
Expand All @@ -26,17 +30,22 @@ export declare class UIElement {
*/
tap(): Promise<any>;
/**
* @experimental
* Double tap on element
*/
doubleTap(): Promise<any>;
longPress(duration: number): Promise<void>;
/**
* Get location of element
*/
location(): Promise<Point>;
/**
* Get size of element
*/
size(): Promise<Point>;
size(): Promise<{
width: number;
height: number;
}>;
/**
* Get text of element
*/
Expand Down Expand Up @@ -113,13 +122,6 @@ export declare class UIElement {
*/
scrollTo(direction: Direction, elementToSearch: () => Promise<UIElement>, yOffset?: number, xOffset?: number, retries?: number): Promise<UIElement>;
/**
* Drag element with specific offset
* @param direction
* @param yOffset
* @param xOffset - default value 0
*/
drag(direction: Direction, yOffset: number, xOffset?: number): Promise<void>;
/**
* Click and hold over an element
* @param time in milliseconds to increase the default press period.
*/
Expand Down Expand Up @@ -165,4 +167,50 @@ export declare class UIElement {
* @param direction
*/
swipe(direction: Direction): Promise<void>;
/**
* Drag element with specific offset
* @experimental
* @param direction
* @param yOffset
* @param xOffset - default value 0
*/
drag(direction: Direction, yOffset: number, xOffset?: number, duration?: number): Promise<void>;
/**
*@experimental
* Pan element with specific offset
* @param points where the finger should move to.
* @param initPointOffset element.getRectangle() is used as start point. In case some additional offset should be provided use this param.
*/
pan(points: {
x: number;
y: number;
}[], initPointOffset?: {
x: number;
y: number;
}): Promise<void>;
/**
* @experimental
* This method will try to move two fingers from opposite corners.
* One finger starts from
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
* and ends to
* { x: elementRect.x + elementRect.width - offset.x, y: elementRect.height + elementRect.y - offset.y }
* and the other finger starts from
* { x: elementRect.width + elementRect.x - offset.x, y: elementRect.height + elementRect.y - offset.y }
* and ends to
* { x: elementRect.x + offset.x, y: elementRect.y + offset.y }
*/
rotate(offset?: {
x: number;
y: number;
}): Promise<void>;
/**
* @experimental
* @param zoomFactory - zoomIn or zoomOut. Only zoomIn action is implemented
* @param offset
*/
pinch(zoomType: "in" | "out", offset?: {
x: number;
y: number;
}): Promise<void>;
}
Loading