Skip to content

Commit ac00ec0

Browse files
Tsenov/animations (#96)
* feature: frame-comparer * fix: ios video recording * fix(android-controller): android video recording * fix: stop recording * fix: frame-comparer * chore: typo * chore: include console.log for err msg * chore: update error msg * feature: devMode, capabiliites parser, appPath * feature: frame-comparer * fix: ios video recording * fix(android-controller): android video recording * fix: stop recording * fix: frame-comparer * chore: typo * chore: include console.log for err msg * chore: update error msg * feature: devMode, capabiliites parser, appPath * feature: expose storage and result paths * chore: fix typos
1 parent 0c9a7ab commit ac00ec0

28 files changed

+407
-154
lines changed

index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { IDeviceManager } from "./lib/interfaces/device-manager";
2+
import * as frameComparerHelper from "./lib/frame-comparer";
23
export { AppiumDriver } from "./lib/appium-driver";
34
export { AppiumServer } from "./lib/appium-server";
45
export { ElementHelper } from "./lib/element-helper";
@@ -8,8 +9,15 @@ export { SearchOptions } from "./lib/search-options";
89
export { Locator } from "./lib/locators";
910
export { Direction } from "./lib/direction";
1011
export { DeviceManger } from "./lib/device-controller";
12+
export { FrameComparer } from "./lib/frame-comparer";
1113
export { IRectangle } from "./lib/interfaces/rectangle";
1214
export { IDeviceManager } from "./lib/interfaces/device-manager";
1315
export declare function startServer(port?: number, deviceManager?: IDeviceManager): Promise<void>;
1416
export declare function stopServer(): Promise<void>;
1517
export declare function createDriver(): Promise<any>;
18+
/**
19+
* Provide instance of FrameComparer in order to compare frames/ images from video
20+
* Please read carefully README.md before using it.
21+
* @throws exception in order the dependecies are not installed properly.
22+
*/
23+
export declare function loadFrameComparer(): frameComparerHelper.FrameComparer;

index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { ElementHelper } from "./lib/element-helper";
44
import { NsCapabilities } from "./lib/ns-capabilities";
55
import { IDeviceManager } from "./lib/interfaces/device-manager";
66
import { shutdown, findFreePort } from "./lib/utils";
7+
import * as frameComparerHelper from "./lib/frame-comparer";
8+
import { FrameComparer } from "./lib/frame-comparer";
79

810
export { AppiumDriver } from "./lib/appium-driver";
911
export { AppiumServer } from "./lib/appium-server";
@@ -14,12 +16,13 @@ export { SearchOptions } from "./lib/search-options";
1416
export { Locator } from "./lib/locators";
1517
export { Direction } from "./lib/direction";
1618
export { DeviceManger } from "./lib/device-controller";
19+
export { FrameComparer } from "./lib/frame-comparer";
1720
export { IRectangle } from "./lib/interfaces/rectangle";
1821
export { IDeviceManager } from "./lib/interfaces/device-manager";
1922

2023
const nsCapabilities = new NsCapabilities();
2124
const appiumServer = new AppiumServer(nsCapabilities);
22-
25+
let frameComparer: FrameComparer;
2326
let appiumDriver = null;
2427

2528
export async function startServer(port?: number, deviceManager?: IDeviceManager) {
@@ -66,6 +69,19 @@ export async function createDriver() {
6669
return appiumDriver;
6770
}
6871

72+
/**
73+
* Provide instance of FrameComparer in order to compare frames/ images from video
74+
* Please read carefully README.md before using it.
75+
* @throws exception in order the dependecies are not installed properly.
76+
*/
77+
export function loadFrameComparer() {
78+
if (!frameComparer) {
79+
frameComparer = frameComparerHelper.loadFrameComparer(nsCapabilities);
80+
}
81+
82+
return frameComparer;
83+
}
84+
6985
const killProcesses = async (code) => {
7086
if (appiumServer) {
7187
return await stopServer();

lib/appium-driver.d.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export declare class AppiumDriver {
2929
readonly imageHelper: ImageHelper;
3030
defaultWaitTime: number;
3131
readonly capabilities: any;
32+
readonly nsCapabilities: INsCapabilities;
3233
readonly platformName: any;
3334
readonly platformVersion: any;
3435
readonly elementHelper: ElementHelper;
@@ -41,6 +42,7 @@ export declare class AppiumDriver {
4142
wd(): any;
4243
click(args: any): Promise<any>;
4344
navBack(): Promise<any>;
45+
static createAppiumDriver(port: number, args: INsCapabilities): Promise<AppiumDriver>;
4446
/**
4547
*
4648
* @param xPath
@@ -132,13 +134,22 @@ export declare class AppiumDriver {
132134
compareElement(element: UIElement, imageName: string, tolerance?: number, timeOutSeconds?: number, toleranceType?: ImageOptions): Promise<boolean>;
133135
compareRectangle(rect: IRectangle, imageName: string, timeOutSeconds?: number, tolerance?: number, toleranceType?: ImageOptions): Promise<boolean>;
134136
compareScreen(imageName: string, timeOutSeconds?: number, tolerance?: number, toleranceType?: ImageOptions): Promise<boolean>;
137+
/**
138+
* @param videoName
139+
* @param callback when to stop video recording. In order an element is found. Should return true to exit
140+
*/
141+
recordVideo(videoName: any, callback: () => Promise<any>): Promise<any>;
142+
private _recordVideoInfo;
143+
/**
144+
* @param videoName
145+
*/
146+
startRecordingVideo(videoName: any): any;
147+
stopRecordingVideo(): Promise<any>;
135148
private compare(imageName, timeOutSeconds?, tolerance?, rect?, toleranceType?);
136149
prepareImageToCompare(filePath: string, rect: IRectangle): Promise<void>;
137150
takeScreenshot(fileName: string): Promise<string>;
138151
logScreenshot(fileName: string): Promise<string>;
139152
logPageSource(fileName: string): Promise<void>;
140-
static createAppiumDriver(port: number, args: INsCapabilities): Promise<AppiumDriver>;
141-
private static applyAdditionalSettings(args);
142153
/**
143154
* Send the currently active app to the background
144155
* @param time
@@ -147,14 +158,20 @@ export declare class AppiumDriver {
147158
resetApp(): Promise<void>;
148159
init(): Promise<void>;
149160
quit(): Promise<void>;
161+
private static applyAdditionalSettings(args);
150162
private convertArrayToUIElements(array, searchM, args);
151163
private static configureLogging(driver, verbose);
152164
private getExpectedImagePath(imageName);
153165
/**
154166
* Wait specific amount of time before continue execution
155167
* @param miliseconds
156168
*/
157-
wait(miliseconds: number): Promise<void>;
169+
sleep(miliseconds: number): Promise<void>;
170+
/**
171+
* Wait specific amount of time before continue execution
172+
* @param miliseconds
173+
*/
174+
wait(miliseconds: number): void;
158175
/**
159176
* Search for element by given xPath but does not throw error if can not find it. Instead returns 'undefined'.
160177
* @param xPath

0 commit comments

Comments
 (0)