From 06da3e6b43bd1d38843d1873538aeb7371cb0a4a Mon Sep 17 00:00:00 2001 From: Winfred van Egteren Date: Sun, 1 Oct 2017 12:03:34 +0200 Subject: [PATCH] fixed some typos + some cleanup --- lib/appium-driver.d.ts | 9 ++++----- lib/appium-driver.ts | 23 +++++++++++------------ lib/image-helper.ts | 2 +- lib/parser.ts | 2 +- lib/simulator-manager.ts | 4 ++-- lib/utils.d.ts | 1 - lib/utils.js | 6 ++---- lib/utils.ts | 13 ++++++------- 8 files changed, 27 insertions(+), 33 deletions(-) diff --git a/lib/appium-driver.d.ts b/lib/appium-driver.d.ts index 48450a8..91b20f5 100644 --- a/lib/appium-driver.d.ts +++ b/lib/appium-driver.d.ts @@ -25,7 +25,7 @@ export declare class AppiumDriver { defaultWaitTime: number; readonly capabilities: any; readonly platformName: any; - readonly platformVesrion: any; + readonly platformVersion: any; readonly elementHelper: ElementHelper; readonly locators: Locator; readonly isAlive: boolean; @@ -88,17 +88,16 @@ export declare class AppiumDriver { findElementsByAccessibilityId(id: string, waitForElement?: number): Promise; /** * Scrolls from point to other point with minimum inertia + * @param direction * @param y * @param x * @param yOffset - * @param duration * @param xOffset */ - scroll(direction: any, SwipeDirection: any, y: number, x: number, yOffset: number, xOffset?: number): Promise; + scroll(direction: Direction, y: number, x: number, yOffset: number, xOffset?: number): Promise; /** * * @param direction - * @param SwipeDirection * @param element * @param startPoint * @param yOffset @@ -123,7 +122,7 @@ export declare class AppiumDriver { logPageSource(fileName: string): Promise; static createAppiumDriver(port: number, args: INsCapabilities): Promise; resetApp(): Promise; - inint(): Promise; + init(): Promise; quit(): Promise; private convertArrayToUIElements(array, searchM, args); private static configureLogging(driver, verbose); diff --git a/lib/appium-driver.ts b/lib/appium-driver.ts index 4fd3860..b43803a 100644 --- a/lib/appium-driver.ts +++ b/lib/appium-driver.ts @@ -64,8 +64,8 @@ export class AppiumDriver { return this._args.appiumCaps.platformName; } - get platformVesrion() { - return this._args.appiumCaps.platformVesrion; + get platformVersion() { + return this._args.appiumCaps.platformVersion; } get elementHelper() { @@ -181,20 +181,19 @@ export class AppiumDriver { /** * Scrolls from point to other point with minimum inertia - * @param y - * @param x - * @param yOffset - * @param duration - * @param xOffset + * @param direction + * @param y + * @param x + * @param yOffset + * @param xOffset */ - public async scroll(direction, SwipeDirection, y: number, x: number, yOffset: number, xOffset: number = 0) { + public async scroll(direction: Direction, y: number, x: number, yOffset: number, xOffset: number = 0) { scroll(this._wd, this._driver, direction, this._webio.isIOS, y, x, yOffset, xOffset, this._args.verbose); } /** * - * @param direction - * @param SwipeDirection + * @param direction * @param element * @param startPoint * @param yOffset @@ -202,7 +201,7 @@ export class AppiumDriver { * @param retryCount */ public async scrollTo(direction: Direction, element: any, startPoint: Point, yOffset: number, xOffset: number = 0, retryCount: number = 7) { - let el = null + let el = null; while (el === null && retryCount > 0) { try { el = await element(); @@ -391,7 +390,7 @@ export class AppiumDriver { await this._driver.resetApp(); } - public async inint() { + public async init() { await this._driver.init(this._args.appiumCaps); this._webio.requestHandler.sessionID = this._driver.sessionID; this._isAlive = true; diff --git a/lib/image-helper.ts b/lib/image-helper.ts index 2279a31..5b1d3a7 100644 --- a/lib/image-helper.ts +++ b/lib/image-helper.ts @@ -45,7 +45,7 @@ export class ImageHelper { console.log('Found ' + result.differences + ' differences.'); return resolve(true); } else { - message = "Screen compare failed!" + message = "Screen compare failed!"; console.log(message); console.log('Found ' + result.differences + ' differences.'); console.log('Diff image: ' + diffImage); diff --git a/lib/parser.ts b/lib/parser.ts index e21a121..6b3ba8b 100644 --- a/lib/parser.ts +++ b/lib/parser.ts @@ -45,7 +45,7 @@ const config = (() => { storage: options.storage || process.env.npm_config_STORAGE || process.env.STORAGE, testReports: options.testReports || process.env.npm_config_TEST_REPORTS || process.env.TEST_REPORTS, reuseDevice: options.reuseDevice || process.env.npm_config_REUSE_DEVICE || process.env.REUSE_DEVICE, - } + }; return config; })(); diff --git a/lib/simulator-manager.ts b/lib/simulator-manager.ts index c637a31..9ea68d8 100644 --- a/lib/simulator-manager.ts +++ b/lib/simulator-manager.ts @@ -5,7 +5,7 @@ import { INsCapabilities } from "./ins-capabilities"; const XCRUN = "xcrun "; const SIMCTL = XCRUN + " simctl "; const XCRUNLISTDEVICES_COMMAND = SIMCTL + " list devices "; -const BOOT_DEVICE_COMMAND = XCRUN + " instruments -w " +const BOOT_DEVICE_COMMAND = XCRUN + " instruments -w "; const BOOTED = "Booted"; const SHUTDOWN = "Shutdown"; const OSASCRIPT_QUIT_SIMULATOR_COMMAND = "osascript -e 'tell application \"Simulator\" to quit'"; @@ -128,7 +128,7 @@ export class SimulatorManager { } private static parseSimulator(sim) { - var parts = sim.split(" ("); + const parts = sim.split(" ("); if (parts.length < 2) { return undefined; } diff --git a/lib/utils.d.ts b/lib/utils.d.ts index c5fe772..88c3146 100644 --- a/lib/utils.d.ts +++ b/lib/utils.d.ts @@ -28,7 +28,6 @@ export declare function calculateOffset(direction: any, y: number, yOffset: numb * @param y * @param x * @param yOffset - * @param duration * @param xOffset */ export declare function scroll(wd: any, driver: any, direction: Direction, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose: any): Promise; diff --git a/lib/utils.js b/lib/utils.js index f9b3ce1..b889dde 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -148,7 +148,7 @@ function contains(source, check) { return source.indexOf(check) >= 0; } exports.contains = contains; -// Search for files and folders. If shoud not match, than the filter will skip this words. Could be use with wildcards +// Search for files and folders. If should not match, than the filter will skip this words. Could be use with wildcards function searchFiles(folder, words, recursive, files) { if (recursive === void 0) { recursive = true; } if (files === void 0) { files = new Array(); } @@ -290,11 +290,10 @@ function getAppPath(platform, runType) { } else { throw new Error("No 'app' capability provided and incorrect 'runType' convention used: " + runType + - ". In order to automatically search and locate app package please use 'android','ios-device','ios-simulator' in your 'runType' option. E.g --runType android23, --runType ios-simulator10iPhone6"); + ". In order to automatically search and locate app package please use 'android','device','sim' in your 'runType' option. E.g --runType android25, --runType sim.iPhone7.iOS110"); } } exports.getAppPath = getAppPath; -; function calculateOffset(direction, y, yOffset, x, xOffset, isIOS, verbose) { var speed = 10; var yEnd = Math.abs(yOffset); @@ -338,7 +337,6 @@ exports.calculateOffset = calculateOffset; * @param y * @param x * @param yOffset - * @param duration * @param xOffset */ function scroll(wd, driver, direction, isIOS, y, x, yOffset, xOffset, verbose) { diff --git a/lib/utils.ts b/lib/utils.ts index ff7e36b..1e495bc 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -72,10 +72,10 @@ export function executeNpmInstall(cwd) { let spawnArgs = []; let command = ""; if (isWin()) { - command = "cmd.exe" + command = "cmd.exe"; spawnArgs = ["/c", "npm", "install"]; } else { - command = "npm" + command = "npm"; spawnArgs = ["install"]; } const npm = childProcess.spawnSync(command, spawnArgs, { cwd: cwd, stdio: "inherit" }); @@ -293,9 +293,9 @@ export function getAppPath(platform, runType) { } } else { throw new Error("No 'app' capability provided and incorrect 'runType' convention used: " + runType + - ". In order to automatically search and locate app package please use 'android','device','sim' in your 'runType' option. E.g --runType android25, --runType sim11iPhone6"); + ". In order to automatically search and locate app package please use 'android','device','sim' in your 'runType' option. E.g --runType android25, --runType sim.iPhone7.iOS110"); } -}; +} export function calculateOffset(direction, y: number, yOffset: number, x: number, xOffset: number, isIOS: boolean, verbose) { let speed = 10; @@ -345,8 +345,7 @@ export function calculateOffset(direction, y: number, yOffset: number, x: number * Scrolls from point to other point with minimum inertia * @param y * @param x - * @param yOffset - * @param duration + * @param yOffset * @param xOffset */ export async function scroll(wd, driver, direction: Direction, isIOS: boolean, y: number, x: number, yOffset: number, xOffset: number, verbose) { @@ -368,7 +367,7 @@ export async function scroll(wd, driver, direction: Direction, isIOS: boolean, y } function createStorageFolder(storage, direcotry) { - storage = resolve(storage, direcotry) + storage = resolve(storage, direcotry); if (!fileExists(storage)) { fs.mkdirSync(storage); }