Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IDeviceManager } from "./lib/interfaces/device-manager";
import * as frameComparerHelper from "./lib/frame-comparer";
export { AppiumDriver } from "./lib/appium-driver";
export { AppiumServer } from "./lib/appium-server";
export { ElementHelper } from "./lib/element-helper";
Expand All @@ -8,8 +9,15 @@ export { SearchOptions } from "./lib/search-options";
export { Locator } from "./lib/locators";
export { Direction } from "./lib/direction";
export { DeviceManger } from "./lib/device-controller";
export { FrameComparer } from "./lib/frame-comparer";
export { IRectangle } from "./lib/interfaces/rectangle";
export { IDeviceManager } from "./lib/interfaces/device-manager";
export declare function startServer(port?: number, deviceManager?: IDeviceManager): Promise<void>;
export declare function stopServer(): Promise<void>;
export declare function createDriver(): Promise<any>;
/**
* Provide instance of FrameComparer in order to compare frames/ images from video
* Please read carefully README.md before using it.
* @throws exception in order the dependecies are not installed properly.
*/
export declare function loadFrameComparer(): frameComparerHelper.FrameComparer;
18 changes: 17 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ElementHelper } from "./lib/element-helper";
import { NsCapabilities } from "./lib/ns-capabilities";
import { IDeviceManager } from "./lib/interfaces/device-manager";
import { shutdown, findFreePort } from "./lib/utils";
import * as frameComparerHelper from "./lib/frame-comparer";
import { FrameComparer } from "./lib/frame-comparer";

export { AppiumDriver } from "./lib/appium-driver";
export { AppiumServer } from "./lib/appium-server";
Expand All @@ -14,12 +16,13 @@ export { SearchOptions } from "./lib/search-options";
export { Locator } from "./lib/locators";
export { Direction } from "./lib/direction";
export { DeviceManger } from "./lib/device-controller";
export { FrameComparer } from "./lib/frame-comparer";
export { IRectangle } from "./lib/interfaces/rectangle";
export { IDeviceManager } from "./lib/interfaces/device-manager";

const nsCapabilities = new NsCapabilities();
const appiumServer = new AppiumServer(nsCapabilities);

let frameComparer: FrameComparer;
let appiumDriver = null;

export async function startServer(port?: number, deviceManager?: IDeviceManager) {
Expand Down Expand Up @@ -66,6 +69,19 @@ export async function createDriver() {
return appiumDriver;
}

/**
* Provide instance of FrameComparer in order to compare frames/ images from video
* Please read carefully README.md before using it.
* @throws exception in order the dependecies are not installed properly.
*/
export function loadFrameComparer() {
if (!frameComparer) {
frameComparer = frameComparerHelper.loadFrameComparer(nsCapabilities);
}

return frameComparer;
}

const killProcesses = async (code) => {
if (appiumServer) {
return await stopServer();
Expand Down
23 changes: 20 additions & 3 deletions lib/appium-driver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export declare class AppiumDriver {
readonly imageHelper: ImageHelper;
defaultWaitTime: number;
readonly capabilities: any;
readonly nsCapabilities: INsCapabilities;
readonly platformName: any;
readonly platformVersion: any;
readonly elementHelper: ElementHelper;
Expand All @@ -41,6 +42,7 @@ export declare class AppiumDriver {
wd(): any;
click(args: any): Promise<any>;
navBack(): Promise<any>;
static createAppiumDriver(port: number, args: INsCapabilities): Promise<AppiumDriver>;
/**
*
* @param xPath
Expand Down Expand Up @@ -132,13 +134,22 @@ export declare class AppiumDriver {
compareElement(element: UIElement, imageName: string, tolerance?: number, timeOutSeconds?: number, toleranceType?: ImageOptions): Promise<boolean>;
compareRectangle(rect: IRectangle, imageName: string, timeOutSeconds?: number, tolerance?: number, toleranceType?: ImageOptions): Promise<boolean>;
compareScreen(imageName: string, timeOutSeconds?: number, tolerance?: number, toleranceType?: ImageOptions): Promise<boolean>;
/**
* @param videoName
* @param callback when to stop video recording. In order an element is found. Should return true to exit
*/
recordVideo(videoName: any, callback: () => Promise<any>): Promise<any>;
private _recordVideoInfo;
/**
* @param videoName
*/
startRecordingVideo(videoName: any): any;
stopRecordingVideo(): Promise<any>;
private compare(imageName, timeOutSeconds?, tolerance?, rect?, toleranceType?);
prepareImageToCompare(filePath: string, rect: IRectangle): Promise<void>;
takeScreenshot(fileName: string): Promise<string>;
logScreenshot(fileName: string): Promise<string>;
logPageSource(fileName: string): Promise<void>;
static createAppiumDriver(port: number, args: INsCapabilities): Promise<AppiumDriver>;
private static applyAdditionalSettings(args);
/**
* Send the currently active app to the background
* @param time
Expand All @@ -147,14 +158,20 @@ export declare class AppiumDriver {
resetApp(): Promise<void>;
init(): Promise<void>;
quit(): Promise<void>;
private static applyAdditionalSettings(args);
private convertArrayToUIElements(array, searchM, args);
private static configureLogging(driver, verbose);
private getExpectedImagePath(imageName);
/**
* Wait specific amount of time before continue execution
* @param miliseconds
*/
wait(miliseconds: number): Promise<void>;
sleep(miliseconds: number): Promise<void>;
/**
* Wait specific amount of time before continue execution
* @param miliseconds
*/
wait(miliseconds: number): void;
/**
* Search for element by given xPath but does not throw error if can not find it. Instead returns 'undefined'.
* @param xPath
Expand Down
Loading