From 52de68080628b5a40fd6c5e9a0bb28c231e94c7b Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 7 Jan 2019 14:44:11 +0000 Subject: [PATCH 1/2] chore(package): update eslint-config-appium to version 4.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f996beda3..05c8efa5b 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "eslint": "^5.2.0", - "eslint-config-appium": "^3.1.0", + "eslint-config-appium": "^4.0.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-mocha": "^5.0.0", "eslint-plugin-promise": "^4.0.0", From 93c60f98fec8af265b8dedd558b28fe5956bed1e Mon Sep 17 00:00:00 2001 From: Isaac Murchie Date: Mon, 7 Jan 2019 10:50:04 -0600 Subject: [PATCH 2/2] chore: fix linting --- gulpfile.js | 2 +- index.js | 2 +- lib/android-helpers.js | 42 ++++++------- lib/bootstrap.js | 2 +- lib/commands/actions.js | 42 ++++++------- lib/commands/context.js | 18 +++--- lib/commands/element.js | 42 ++++++------- lib/commands/find.js | 2 +- lib/commands/ime.js | 8 +-- lib/commands/index.js | 4 +- lib/commands/network.js | 6 +- lib/commands/performance.js | 44 +++++++------- lib/commands/touch.js | 12 ++-- lib/driver.js | 26 ++++---- lib/unlock-helpers.js | 36 +++++------ lib/webview-helpers.js | 24 ++++---- .../bootstrap/bootstrap-e2e-specs.js | 12 ++-- test/functional/chrome-e2e-specs.js | 6 +- .../commands/basic/attribute-e2e-specs.js | 2 +- .../commands/find/by-xpath-e2e-specs.js | 4 +- .../commands/geo-location-e2e-specs.js | 2 +- .../commands/keyboard/keyboard-e2e-specs.js | 2 +- .../commands/touch/drag-e2e-specs.js | 40 ++++++------- test/functional/driver-e2e-specs.js | 2 +- test/functional/unlocker-e2e-specs.js | 28 ++++----- .../webview-browser-tester-e2e-specs.js | 2 +- test/unit/android-helper-specs.js | 60 +++++++++---------- test/unit/commands/context-specs.js | 4 +- test/unit/commands/general-specs.js | 2 +- test/unit/driver-specs.js | 40 ++++++------- test/unit/unlock-helper-specs.js | 18 +++--- 31 files changed, 268 insertions(+), 268 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index bdb5fd2dc..dd6610f91 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; const { exec } = require('teen_process'); const system = require('appium-support').system; diff --git a/index.js b/index.js index 4b543ac6f..b23032eaf 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ import * as server from './lib/server'; const { startServer } = server; -const DEFAULT_HOST = "localhost"; +const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 4723; async function main () { diff --git a/lib/android-helpers.js b/lib/android-helpers.js index 639ff5359..dc3ebcf79 100644 --- a/lib/android-helpers.js +++ b/lib/android-helpers.js @@ -81,10 +81,10 @@ helpers.createBaseADB = async function (opts = {}) { }; helpers.parseJavaVersion = function (stderr) { - let lines = stderr.split("\n"); + let lines = stderr.split('\n'); for (let line of lines) { if (new RegExp(/(java|openjdk) version/).test(line)) { - return line.split(" ")[2].replace(/"/g, ''); + return line.split(' ')[2].replace(/"/g, ''); } } return null; @@ -94,7 +94,7 @@ helpers.getJavaVersion = async function (logVersion = true) { let {stderr} = await exec('java', ['-version']); let javaVer = helpers.parseJavaVersion(stderr); if (javaVer === null) { - throw new Error("Could not get the Java version. Is Java installed?"); + throw new Error('Could not get the Java version. Is Java installed?'); } if (logVersion) { logger.info(`Java version is: ${javaVer}`); @@ -112,16 +112,16 @@ helpers.prepareEmulator = async function (adb, opts) { avdReadyTimeout, } = opts; if (!avd) { - throw new Error("Cannot launch AVD without AVD name"); + throw new Error('Cannot launch AVD without AVD name'); } let avdName = avd.replace('@', ''); let runningAVD = await adb.getRunningAVD(avdName); if (runningAVD !== null) { - if (avdArgs && avdArgs.toLowerCase().indexOf("-wipe-data") > -1) { + if (avdArgs && avdArgs.toLowerCase().indexOf('-wipe-data') > -1) { logger.debug(`Killing '${avdName}' because it needs to be wiped at start.`); await adb.killEmulator(avdName); } else { - logger.debug("Not launching AVD because it is already running."); + logger.debug('Not launching AVD because it is already running.'); return; } } @@ -193,7 +193,7 @@ helpers.getDeviceInfoFromCaps = async function (opts = {}) { emPort = adb.emulatorPort; } else { // no avd given. lets try whatever's plugged in devices/emulators - logger.info("Retrieving device list"); + logger.info('Retrieving device list'); let devices = await adb.getDevicesWithRetry(); // udid was given, lets try to init with that device @@ -279,7 +279,7 @@ helpers.validatePackageActivityNames = function (opts) { helpers.getLaunchInfo = async function (adb, opts) { let {app, appPackage, appActivity, appWaitPackage, appWaitActivity} = opts; if (!app) { - logger.warn("No app sent in, not parsing package/activity"); + logger.warn('No app sent in, not parsing package/activity'); return; } @@ -289,7 +289,7 @@ helpers.getLaunchInfo = async function (adb, opts) { return; } - logger.debug("Parsing package and activity from app manifest"); + logger.debug('Parsing package and activity from app manifest'); let {apkPackage, apkActivity} = await adb.packageAndLaunchActivityFromManifest(app); if (apkPackage && !appPackage) { @@ -460,7 +460,7 @@ helpers.installHelperApp = async function (adb, apkPath, packageId, appName) { }; helpers.pushSettingsApp = async function (adb, throwError = false) { - logger.debug("Pushing settings apk to device..."); + logger.debug('Pushing settings apk to device...'); await helpers.installHelperApp(adb, settingsApkPath, SETTINGS_HELPER_PKG_ID, 'Settings'); @@ -489,9 +489,9 @@ helpers.pushSettingsApp = async function (adb, throwError = false) { await adb.startApp({ pkg: SETTINGS_HELPER_PKG_ID, activity: SETTINGS_HELPER_MAIN_ACTIVITY, - action: "android.intent.action.MAIN", - category: "android.intent.category.LAUNCHER", - flags: "0x10200000", + action: 'android.intent.action.MAIN', + category: 'android.intent.category.LAUNCHER', + flags: '0x10200000', stopApp: false, }); } catch (err) { @@ -570,7 +570,7 @@ helpers.unlockWithUIAutomation = async function (driver, adb, unlockCapabilities }; helpers.unlockWithHelperApp = async function (adb) { - logger.info("Unlocking screen"); + logger.info('Unlocking screen'); // Unlock succeed with a couple of retries. let firstRun = true; @@ -585,8 +585,8 @@ helpers.unlockWithHelperApp = async function (adb) { } } catch (e) { logger.warn(`Error in isScreenLocked: ${e.message}`); - logger.warn("\"adb shell dumpsys window\" command has timed out."); - logger.warn("The reason of this timeout is the delayed adb response. Resetting adb server can improve it."); + logger.warn('"adb shell dumpsys window" command has timed out.'); + logger.warn('The reason of this timeout is the delayed adb response. Resetting adb server can improve it.'); } } @@ -604,13 +604,13 @@ helpers.unlockWithHelperApp = async function (adb) { helpers.unlock = async function (driver, adb, capabilities) { if (!(await adb.isScreenLocked())) { - logger.info("Screen already unlocked, doing nothing"); + logger.info('Screen already unlocked, doing nothing'); return; } - logger.debug("Screen is locked, trying to unlock"); + logger.debug('Screen is locked, trying to unlock'); if (_.isUndefined(capabilities.unlockType)) { - logger.warn("Using app unlock, this is going to be deprecated!"); + logger.warn('Using app unlock, this is going to be deprecated!'); await helpers.unlockWithHelperApp(adb); } else { await helpers.unlockWithUIAutomation(driver, adb, {unlockType: capabilities.unlockType, unlockKey: capabilities.unlockKey}); @@ -621,9 +621,9 @@ helpers.unlock = async function (driver, adb, capabilities) { helpers.verifyUnlock = async function (adb) { await retryInterval(2, 1000, async () => { if (await adb.isScreenLocked()) { - throw new Error("Screen did not unlock successfully, retrying"); + throw new Error('Screen did not unlock successfully, retrying'); } - logger.debug("Screen unlocked successfully"); + logger.debug('Screen unlocked successfully'); }); }; diff --git a/lib/bootstrap.js b/lib/bootstrap.js index b0a29b2aa..22e8927a4 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -98,7 +98,7 @@ class AndroidBootstrap { } }); this.socketClient.once('connect', () => { - log.info("Android bootstrap socket is now connected"); + log.info('Android bootstrap socket is now connected'); resolve(); }); } catch (err) { diff --git a/lib/commands/actions.js b/lib/commands/actions.js index 00e2c5ac3..7364fd4b3 100644 --- a/lib/commands/actions.js +++ b/lib/commands/actions.js @@ -19,23 +19,23 @@ let commands = {}, helpers = {}, extensions = {}; commands.keyevent = async function (keycode, metastate = null) { // TODO deprecate keyevent; currently wd only implements keyevent - log.warn("keyevent will be deprecated use pressKeyCode"); + log.warn('keyevent will be deprecated use pressKeyCode'); return await this.pressKeyCode(keycode, metastate); }; commands.pressKeyCode = async function (keycode, metastate = null) { - return await this.bootstrap.sendAction("pressKeyCode", {keycode, metastate}); + return await this.bootstrap.sendAction('pressKeyCode', {keycode, metastate}); }; commands.longPressKeyCode = async function (keycode, metastate = null) { - return await this.bootstrap.sendAction("longPressKeyCode", {keycode, metastate}); + return await this.bootstrap.sendAction('longPressKeyCode', {keycode, metastate}); }; commands.getOrientation = async function () { let params = { naturalOrientation: !!this.opts.androidNaturalOrientation, }; - let orientation = await this.bootstrap.sendAction("orientation", params); + let orientation = await this.bootstrap.sendAction('orientation', params); return orientation.toUpperCase(); }; @@ -45,7 +45,7 @@ commands.setOrientation = async function (orientation) { orientation, naturalOrientation: !!this.opts.androidNaturalOrientation, }; - return await this.bootstrap.sendAction("orientation", params); + return await this.bootstrap.sendAction('orientation', params); }; commands.fakeFlick = async function (xSpeed, ySpeed) { @@ -76,9 +76,9 @@ commands.swipe = async function (startX, startY, endX, endY, duration, touchCoun commands.doSwipe = async function (swipeOpts) { if (util.hasValue(swipeOpts.elementId)) { - return await this.bootstrap.sendAction("element:swipe", swipeOpts); + return await this.bootstrap.sendAction('element:swipe', swipeOpts); } else { - return await this.bootstrap.sendAction("swipe", swipeOpts); + return await this.bootstrap.sendAction('swipe', swipeOpts); } }; @@ -89,12 +89,12 @@ commands.pinchClose = async function (startX, startY, endX, endY, duration, perc percent, steps }; - return await this.bootstrap.sendAction("element:pinch", pinchOpts); + return await this.bootstrap.sendAction('element:pinch', pinchOpts); }; commands.pinchOpen = async function (startX, startY, endX, endY, duration, percent, steps, elId) { let pinchOpts = {direction: 'out', elementId: elId, percent, steps}; - return await this.bootstrap.sendAction("element:pinch", pinchOpts); + return await this.bootstrap.sendAction('element:pinch', pinchOpts); }; commands.flick = async function (element, xSpeed, ySpeed, xOffset, yOffset, speed) { @@ -116,9 +116,9 @@ commands.drag = async function (startX, startY, endX, endY, duration, touchCount commands.doDrag = async function (dragOpts) { if (util.hasValue(dragOpts.elementId)) { - return await this.bootstrap.sendAction("element:drag", dragOpts); + return await this.bootstrap.sendAction('element:drag', dragOpts); } else { - return await this.bootstrap.sendAction("drag", dragOpts); + return await this.bootstrap.sendAction('drag', dragOpts); } }; @@ -145,7 +145,7 @@ commands.unlock = async function () { }; commands.openNotifications = async function () { - return await this.bootstrap.sendAction("openNotification"); + return await this.bootstrap.sendAction('openNotification'); }; commands.setLocation = async function (latitude, longitude) { @@ -233,7 +233,7 @@ commands.pushFile = async function (remotePath, base64Data) { // if we have pushed a file, it might be a media file, so ensure that // apps know about it - log.info("After pushing media file, broadcasting media scan intent"); + log.info('After pushing media file, broadcasting media scan intent'); try { await this.adb.shell(['am', 'broadcast', '-a', ANDROID_MEDIA_RESCAN_INTENT, '-d', `file://${remotePath}`]); @@ -259,56 +259,56 @@ commands.pullFolder = async function (remotePath) { commands.fingerprint = async function (fingerprintId) { if (!this.isEmulator()) { - log.errorAndThrow("fingerprint method is only available for emulators"); + log.errorAndThrow('fingerprint method is only available for emulators'); } await this.adb.fingerprint(fingerprintId); }; commands.sendSMS = async function (phoneNumber, message) { if (!this.isEmulator()) { - log.errorAndThrow("sendSMS method is only available for emulators"); + log.errorAndThrow('sendSMS method is only available for emulators'); } await this.adb.sendSMS(phoneNumber, message); }; commands.gsmCall = async function (phoneNumber, action) { if (!this.isEmulator()) { - log.errorAndThrow("gsmCall method is only available for emulators"); + log.errorAndThrow('gsmCall method is only available for emulators'); } await this.adb.gsmCall(phoneNumber, action); }; commands.gsmSignal = async function (signalStrengh) { if (!this.isEmulator()) { - log.errorAndThrow("gsmSignal method is only available for emulators"); + log.errorAndThrow('gsmSignal method is only available for emulators'); } await this.adb.gsmSignal(signalStrengh); }; commands.gsmVoice = async function (state) { if (!this.isEmulator()) { - log.errorAndThrow("gsmVoice method is only available for emulators"); + log.errorAndThrow('gsmVoice method is only available for emulators'); } await this.adb.gsmVoice(state); }; commands.powerAC = async function (state) { if (!this.isEmulator()) { - log.errorAndThrow("powerAC method is only available for emulators"); + log.errorAndThrow('powerAC method is only available for emulators'); } await this.adb.powerAC(state); }; commands.powerCapacity = async function (batteryPercent) { if (!this.isEmulator()) { - log.errorAndThrow("powerCapacity method is only available for emulators"); + log.errorAndThrow('powerCapacity method is only available for emulators'); } await this.adb.powerCapacity(batteryPercent); }; commands.networkSpeed = async function (networkSpeed) { if (!this.isEmulator()) { - log.errorAndThrow("networkSpeed method is only available for emulators"); + log.errorAndThrow('networkSpeed method is only available for emulators'); } await this.adb.networkSpeed(networkSpeed); }; diff --git a/lib/commands/context.js b/lib/commands/context.js index 1fef75d31..13d06df22 100644 --- a/lib/commands/context.js +++ b/lib/commands/context.js @@ -69,7 +69,7 @@ helpers.switchContext = async function (name) { // to true then kill chromedriver session using stopChromedriverProxies or // else simply suspend proxying to the latter if (this.opts.recreateChromeDriverSessions) { - log.debug("recreateChromeDriverSessions set to true; killing existing chromedrivers"); + log.debug('recreateChromeDriverSessions set to true; killing existing chromedrivers'); await this.stopChromedriverProxies(); } else { await this.suspendChromedriverProxy(); @@ -150,13 +150,13 @@ helpers.onChromedriverStop = async function (context) { if (context === this.curContext) { // we exited unexpectedly while automating the current context and so want // to shut down the session and respond with an error - let err = new Error("Chromedriver quit unexpectedly during session"); + let err = new Error('Chromedriver quit unexpectedly during session'); await this.startUnexpectedShutdown(err); } else { // if a Chromedriver in the non-active context barfs, we don't really // care, we'll just make a new one next time we need the context. log.warn("Chromedriver quit unexpectedly, but it wasn't the active " + - "context, ignoring"); + 'context, ignoring'); delete this.sessionChromedrivers[context]; } }; @@ -190,10 +190,10 @@ helpers.shouldDismissChromeWelcome = function shouldDismissChromeWelcome () { }; helpers.dismissChromeWelcome = async function dismissChromeWelcome () { - log.info("Trying to dismiss Chrome welcome"); + log.info('Trying to dismiss Chrome welcome'); let activity = await this.getCurrentActivity(); - if (activity !== "org.chromium.chrome.browser.firstrun.FirstRunActivity") { - log.info("Chrome welcome dialog never showed up! Continuing"); + if (activity !== 'org.chromium.chrome.browser.firstrun.FirstRunActivity') { + log.info('Chrome welcome dialog never showed up! Continuing'); return; } let el = await this.findElOrEls('id', 'com.android.chrome:id/terms_accept', false); @@ -209,7 +209,7 @@ helpers.dismissChromeWelcome = async function dismissChromeWelcome () { }; helpers.startChromeSession = async function startChromeSession () { - log.info("Starting a chrome-based browser session"); + log.info('Starting a chrome-based browser session'); let opts = _.cloneDeep(this.opts); opts.chromeUseRunningApp = false; @@ -256,8 +256,8 @@ async function setupExistingChromedriver (chromedriver) { // check the status by sending a simple window-based command to ChromeDriver // if there is an error, we want to recreate the ChromeDriver session if (!await chromedriver.hasWorkingWebview()) { - log.debug("ChromeDriver is not associated with a window. " + - "Re-initializing the session."); + log.debug('ChromeDriver is not associated with a window. ' + + 'Re-initializing the session.'); await chromedriver.restart(); } return chromedriver; diff --git a/lib/commands/element.js b/lib/commands/element.js index 8a5fea9dc..fa9099993 100644 --- a/lib/commands/element.js +++ b/lib/commands/element.js @@ -7,29 +7,29 @@ let commands = {}, helpers = {}, extensions = {}; commands.getAttribute = async function (attribute, elementId) { let p = {attribute, elementId}; - return await this.bootstrap.sendAction("element:getAttribute", p); + return await this.bootstrap.sendAction('element:getAttribute', p); }; commands.getName = async function (elementId) { - return await this.getAttribute("className", elementId); + return await this.getAttribute('className', elementId); }; commands.elementDisplayed = async function (elementId) { - return await this.getAttribute("displayed", elementId) === 'true'; + return await this.getAttribute('displayed', elementId) === 'true'; }; commands.elementEnabled = async function (elementId) { - return await this.getAttribute("enabled", elementId) === 'true'; + return await this.getAttribute('enabled', elementId) === 'true'; }; commands.elementSelected = async function (elementId) { - return await this.getAttribute("selected", elementId) === 'true'; + return await this.getAttribute('selected', elementId) === 'true'; }; helpers.setElementValue = async function (keys, elementId, replace = false) { let text = keys; if (keys instanceof Array) { - text = keys.join(""); + text = keys.join(''); } let params = { @@ -49,7 +49,7 @@ helpers.setElementValue = async function (keys, elementId, replace = false) { * to facilitate setElementValue. */ helpers.doSetElementValue = async function (params) { - return await this.bootstrap.sendAction("element:setText", params); + return await this.bootstrap.sendAction('element:setText', params); }; commands.setValue = async function (keys, elementId) { @@ -63,7 +63,7 @@ commands.replaceValue = async function (keys, elementId) { commands.setValueImmediate = async function (keys, elementId) { let text = keys; if (keys instanceof Array) { - text = keys.join(""); + text = keys.join(''); } // first, make sure we are focused on the element @@ -74,7 +74,7 @@ commands.setValueImmediate = async function (keys, elementId) { }; commands.getText = async function (elementId) { - return await this.bootstrap.sendAction("element:getText", {elementId}); + return await this.bootstrap.sendAction('element:getText', {elementId}); }; commands.clear = async function (elementId) { @@ -102,11 +102,11 @@ commands.clear = async function (elementId) { }; commands.click = async function (elementId) { - return await this.bootstrap.sendAction("element:click", {elementId}); + return await this.bootstrap.sendAction('element:click', {elementId}); }; commands.getLocation = async function (elementId) { - return await this.bootstrap.sendAction("element:getLocation", {elementId}); + return await this.bootstrap.sendAction('element:getLocation', {elementId}); }; commands.getLocationInView = async function (elementId) { @@ -114,39 +114,39 @@ commands.getLocationInView = async function (elementId) { }; commands.getSize = async function (elementId) { - return await this.bootstrap.sendAction("element:getSize", {elementId}); + return await this.bootstrap.sendAction('element:getSize', {elementId}); }; commands.getElementRect = async function (elementId) { - return await this.bootstrap.sendAction("element:getRect", {elementId}); + return await this.bootstrap.sendAction('element:getRect', {elementId}); }; commands.touchLongClick = async function (elementId, x, y, duration) { let params = {elementId, x, y, duration}; androidHelpers.removeNullProperties(params); - return await this.bootstrap.sendAction("element:touchLongClick", params); + return await this.bootstrap.sendAction('element:touchLongClick', params); }; commands.touchDown = async function (elementId, x, y) { let params = {elementId, x, y}; androidHelpers.removeNullProperties(params); - return await this.bootstrap.sendAction("element:touchDown", params); + return await this.bootstrap.sendAction('element:touchDown', params); }; commands.touchUp = async function (elementId, x, y) { let params = {elementId, x, y}; androidHelpers.removeNullProperties(params); - return await this.bootstrap.sendAction("element:touchUp", params); + return await this.bootstrap.sendAction('element:touchUp', params); }; commands.touchMove = async function (elementId, x, y) { let params = {elementId, x, y}; androidHelpers.removeNullProperties(params); - return await this.bootstrap.sendAction("element:touchMove", params); + return await this.bootstrap.sendAction('element:touchMove', params); }; commands.complexTap = async function (tapCount, touchCount, duration, x, y) { - return await this.bootstrap.sendAction("click", {x, y}); + return await this.bootstrap.sendAction('click', {x, y}); }; commands.tap = async function (elementId, x = 0, y = 0, count = 1) { @@ -155,12 +155,12 @@ commands.tap = async function (elementId, x = 0, y = 0, count = 1) { // we are either tapping on the default location of the element // or an offset from the top left corner if (x !== 0 || y !== 0) { - await this.bootstrap.sendAction("element:click", {elementId, x, y}); + await this.bootstrap.sendAction('element:click', {elementId, x, y}); } else { - await this.bootstrap.sendAction("element:click", {elementId}); + await this.bootstrap.sendAction('element:click', {elementId}); } } else { - await this.bootstrap.sendAction("click", {x, y}); + await this.bootstrap.sendAction('click', {x, y}); } } }; diff --git a/lib/commands/find.js b/lib/commands/find.js index 685058a84..3c0292d76 100644 --- a/lib/commands/find.js +++ b/lib/commands/find.js @@ -20,7 +20,7 @@ helpers.doFindElementOrEls = async function (params) { // context: finding an element from the root context? or starting from another element helpers.findElOrEls = async function (strategy, selector, mult, context = '') { if (!selector) { - throw new Error("Must provide a selector when finding elements"); + throw new Error('Must provide a selector when finding elements'); } let params = { diff --git a/lib/commands/ime.js b/lib/commands/ime.js index 9db6b3263..adac124b0 100644 --- a/lib/commands/ime.js +++ b/lib/commands/ime.js @@ -9,14 +9,14 @@ commands.isIMEActivated = async function () { // eslint-disable-line require-awa }; commands.availableIMEEngines = async function () { - log.debug("Retrieving available IMEs"); + log.debug('Retrieving available IMEs'); let engines = await this.adb.availableIMEs(); log.debug(`Engines: ${JSON.stringify(engines)}`); return engines; }; commands.getActiveIMEEngine = async function () { - log.debug("Retrieving current default IME"); + log.debug('Retrieving current default IME'); return await this.adb.defaultIME(); }; @@ -24,10 +24,10 @@ commands.activateIMEEngine = async function (imeId) { log.debug(`Attempting to activate IME ${imeId}`); let availableEngines = await this.adb.availableIMEs(); if (availableEngines.indexOf(imeId) === -1) { - log.debug("IME not found, failing"); + log.debug('IME not found, failing'); throw new errors.IMENotAvailableError(); } - log.debug("Found installed IME, attempting to activate"); + log.debug('Found installed IME, attempting to activate'); await this.adb.enableIME(imeId); await this.adb.setIME(imeId); }; diff --git a/lib/commands/index.js b/lib/commands/index.js index a7e914ed7..f48f6f0ab 100644 --- a/lib/commands/index.js +++ b/lib/commands/index.js @@ -10,8 +10,8 @@ import networkCmds from './network'; import coverageCmds from './coverage'; import recordscreenCmds from './recordscreen'; import performanceCmds from './performance'; -import executeCmds from "./execute"; -import shellCmds from "./shell"; +import executeCmds from './execute'; +import shellCmds from './shell'; import appManagementCmds from './app-management'; import logCmds from './log'; diff --git a/lib/commands/network.js b/lib/commands/network.js index d9149b837..d60895491 100644 --- a/lib/commands/network.js +++ b/lib/commands/network.js @@ -11,7 +11,7 @@ const WIFI_MASK = 0b010; const DATA_MASK = 0b100; commands.getNetworkConnection = async function () { - log.info("Getting network connection"); + log.info('Getting network connection'); let airplaneModeOn = await this.adb.isAirplaneModeOn(); let connection = airplaneModeOn ? AIRPLANE_MODE_MASK : 0; @@ -34,7 +34,7 @@ commands.isWifiOn = async function () { }; commands.setNetworkConnection = async function (type) { - log.info("Setting network connection"); + log.info('Setting network connection'); // decode the input const shouldEnableAirplaneMode = (type & AIRPLANE_MODE_MASK) !== 0; const shouldEnableWifi = (type & WIFI_MASK) !== 0; @@ -139,7 +139,7 @@ commands.getGeoLocation = async function () { }; commands.toggleLocationServices = async function () { - log.info("Toggling location services"); + log.info('Toggling location services'); let api = await this.adb.getApiLevel(); if (this.isEmulator()) { let providers = await this.adb.getLocationProviders(); diff --git a/lib/commands/performance.js b/lib/commands/performance.js index eeedfb02c..296f3e044 100644 --- a/lib/commands/performance.js +++ b/lib/commands/performance.js @@ -220,23 +220,23 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { // st=1478095200 rb=10079213 rp=19962 tb=2487705 tp=20015 op=0 // st=1478098800 rb=4444433 rp=10227 tb=1430356 tp=10493 op=0 let index = 0; - let fromXtstats = data.indexOf("Xt stats:"); + let fromXtstats = data.indexOf('Xt stats:'); - let start = data.indexOf("Pending bytes:", fromXtstats); - let delimiter = data.indexOf(":", start + 1); - let end = data.indexOf("\n", delimiter + 1); + let start = data.indexOf('Pending bytes:', fromXtstats); + let delimiter = data.indexOf(':', start + 1); + let end = data.indexOf('\n', delimiter + 1); let pendingBytes = data.substring(delimiter + 1, end).trim(); if (end > delimiter) { - start = data.indexOf("bucketDuration", end + 1); - delimiter = data.indexOf("=", start + 1); - end = data.indexOf("\n", delimiter + 1); + start = data.indexOf('bucketDuration', end + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf('\n', delimiter + 1); bucketDuration = data.substring(delimiter + 1, end).trim(); } if (start >= 0) { data = data.substring(end + 1, data.length); - let arrayList = data.split("\n"); + let arrayList = data.split('\n'); if (arrayList.length > 0) { start = -1; @@ -261,15 +261,15 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { start = data.indexOf(NETWORK_KEYS[index][0]); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); bucketStart = data.substring(delimiter + 1, end).trim(); if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][1], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); activeTime = data.substring(delimiter + 1, end).trim(); } } @@ -277,8 +277,8 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][2], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); rxBytes = data.substring(delimiter + 1, end).trim(); } } @@ -286,8 +286,8 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][3], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); rxPackets = data.substring(delimiter + 1, end).trim(); } } @@ -295,8 +295,8 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][4], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); txBytes = data.substring(delimiter + 1, end).trim(); } } @@ -304,8 +304,8 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][5], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); - end = data.indexOf(" ", delimiter + 1); + delimiter = data.indexOf('=', start + 1); + end = data.indexOf(' ', delimiter + 1); txPackets = data.substring(delimiter + 1, end).trim(); } } @@ -313,7 +313,7 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { if (end > delimiter) { start = data.indexOf(NETWORK_KEYS[index][6], end + 1); if (start >= 0) { - delimiter = data.indexOf("=", start + 1); + delimiter = data.indexOf('=', start + 1); end = data.length; operations = data.substring(delimiter + 1, end).trim(); @@ -325,7 +325,7 @@ helpers.getNetworkTrafficInfo = async function (dataReadTimeout = 2) { } } - if (!_.isEqual(pendingBytes, "") && !_.isUndefined(pendingBytes) && !_.isEqual(pendingBytes, "nodex")) { + if (!_.isEqual(pendingBytes, '') && !_.isUndefined(pendingBytes) && !_.isEqual(pendingBytes, 'nodex')) { return returnValue; } else { throw new Error(`Unable to parse network traffic data: '${data}'`); diff --git a/lib/commands/touch.js b/lib/commands/touch.js index 5a8a11124..63d6f02c6 100644 --- a/lib/commands/touch.js +++ b/lib/commands/touch.js @@ -26,7 +26,7 @@ commands.doTouchAction = async function (action, opts) { return await this.touchLongClick(opts.element, opts.x, opts.y, opts.duration); case 'cancel': // TODO: clarify behavior of 'cancel' action and fix this - log.warn("Cancel action currently has no effect"); + log.warn('Cancel action currently has no effect'); break; default: log.errorAndThrow(`unknown action ${action}`); @@ -148,7 +148,7 @@ commands.performTouch = async function (gestures) { swipeOpts.endY, swipeOpts.duration, swipeOpts.touchCount, swipeOpts.element); } - let actions = _.map(gestures, "action"); + let actions = _.map(gestures, 'action'); if (actions[0] === 'longPress' && actions[1] === 'moveTo' && actions[2] === 'release') { // some things are special @@ -292,8 +292,8 @@ commands.performMultiAction = async function (actions, elementId) { // Android needs at least two actions to be able to perform a multi pointer gesture if (actions.length === 1) { - throw new Error("Multi Pointer Gestures need at least two actions. " + - "Use Touch Actions for a single action."); + throw new Error('Multi Pointer Gestures need at least two actions. ' + + 'Use Touch Actions for a single action.'); } let states = await asyncmap(actions, async (action) => { @@ -316,12 +316,12 @@ commands.doPerformMultiAction = async function (elementId, states) { elementId, actions: states }; - return await this.bootstrap.sendAction("element:performMultiPointerGesture", opts); + return await this.bootstrap.sendAction('element:performMultiPointerGesture', opts); } else { opts = { actions: states }; - return await this.bootstrap.sendAction("performMultiPointerGesture", opts); + return await this.bootstrap.sendAction('performMultiPointerGesture', opts); } }; diff --git a/lib/driver.js b/lib/driver.js index fb8921195..35e155caf 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -76,9 +76,9 @@ class AndroidDriver extends BaseDriver { // assigning defaults let defaultOpts = { - action: "android.intent.action.MAIN", - category: "android.intent.category.LAUNCHER", - flags: "0x10200000", + action: 'android.intent.action.MAIN', + category: 'android.intent.category.LAUNCHER', + flags: '0x10200000', disableAndroidWatchers: false, tmpDir: await tempDir.staticDir(), fullReset: false, @@ -140,7 +140,7 @@ class AndroidDriver extends BaseDriver { if (await this.adb.getApiLevel() >= 23) { log.warn("Consider setting 'automationName' capability to " + "'uiautomator2' on Android >= 6, since UIAutomator framework " + - "is not maintained anymore by the OS vendor."); + 'is not maintained anymore by the OS vendor.'); } if (this.helpers.isPackageOrBundle(this.opts.app)) { @@ -167,7 +167,7 @@ class AndroidDriver extends BaseDriver { // is set for emulators by calling adb.networkSpeed before running the app if (util.hasValue(this.opts.networkSpeed)) { if (!this.isEmulator()) { - log.warn("Sorry, networkSpeed capability is only available for emulators"); + log.warn('Sorry, networkSpeed capability is only available for emulators'); } else { let networkSpeed = helpers.ensureNetworkSpeed(this.adb, this.opts.networkSpeed); await this.adb.networkSpeed(networkSpeed); @@ -176,7 +176,7 @@ class AndroidDriver extends BaseDriver { // check if we have to enable/disable gps before running the application if (util.hasValue(this.opts.gpsEnabled)) { if (this.isEmulator()) { - log.info(`Trying to ${this.opts.gpsEnabled ? "enable" : "disable"} gps location provider`); + log.info(`Trying to ${this.opts.gpsEnabled ? 'enable' : 'disable'} gps location provider`); await this.adb.toggleGPSLocationProvider(this.opts.gpsEnabled); } else { log.warn('Sorry! gpsEnabled capability is only available for emulators'); @@ -209,7 +209,7 @@ class AndroidDriver extends BaseDriver { if (!caps.platformVersion) { log.errorAndThrow('avd or platformVersion should be specified when reboot option is enabled'); } - let avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, "-"); + let avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-'); this.opts.avd = `${avdDevice}__${caps.platformVersion}`; } } @@ -224,7 +224,7 @@ class AndroidDriver extends BaseDriver { } async onSettingsUpdate (key, value) { - if (key === "ignoreUnimportantViews") { + if (key === 'ignoreUnimportantViews') { await this.setCompressedLayoutHierarchy(value); } } @@ -365,14 +365,14 @@ class AndroidDriver extends BaseDriver { } async checkAppPresent () { - log.debug("Checking whether app is actually present"); + log.debug('Checking whether app is actually present'); if (!(await fs.exists(this.opts.app))) { log.errorAndThrow(`Could not find app apk at ${this.opts.app}`); } } async checkPackagePresent () { - log.debug("Checking whether package is present on the device"); + log.debug('Checking whether package is present on the device'); if (!(await this.adb.shell(['pm', 'list', 'packages', this.opts.appPackage]))) { log.errorAndThrow(`Could not find package ${this.opts.appPackage} on the device`); } @@ -380,11 +380,11 @@ class AndroidDriver extends BaseDriver { // Set CompressedLayoutHierarchy on the device async setCompressedLayoutHierarchy (compress) { - await this.bootstrap.sendAction("compressedLayoutHierarchy", {compressLayout: compress}); + await this.bootstrap.sendAction('compressedLayoutHierarchy', {compressLayout: compress}); } async deleteSession () { - log.debug("Shutting down Android driver"); + log.debug('Shutting down Android driver'); await helpers.removeAllSessionWebSocketHandlers(this.server, this.sessionId); await super.deleteSession(); if (this.bootstrap) { @@ -446,7 +446,7 @@ class AndroidDriver extends BaseDriver { async setSharedPreferences () { let sharedPrefs = this.opts.sharedPreferences; - log.info("Trying to set shared preferences"); + log.info('Trying to set shared preferences'); let name = sharedPrefs.name; if (_.isUndefined(name)) { log.warn(`Skipping setting Shared preferences, name is undefined: ${JSON.stringify(sharedPrefs)}`); diff --git a/lib/unlock-helpers.js b/lib/unlock-helpers.js index 1a8abf06e..06192fb0d 100644 --- a/lib/unlock-helpers.js +++ b/lib/unlock-helpers.js @@ -3,12 +3,12 @@ import { sleep } from 'asyncbox'; import _ from 'lodash'; import { util } from 'appium-support'; -const PIN_UNLOCK = "pin"; -const PASSWORD_UNLOCK = "password"; -const PATTERN_UNLOCK = "pattern"; -const FINGERPRINT_UNLOCK = "fingerprint"; +const PIN_UNLOCK = 'pin'; +const PASSWORD_UNLOCK = 'password'; +const PATTERN_UNLOCK = 'pattern'; +const FINGERPRINT_UNLOCK = 'fingerprint'; const UNLOCK_TYPES = [PIN_UNLOCK, PASSWORD_UNLOCK, PATTERN_UNLOCK, FINGERPRINT_UNLOCK]; -const KEYCODE_NUMPAD_ENTER = "66"; +const KEYCODE_NUMPAD_ENTER = '66'; const UNLOCK_WAIT_TIME = 100; const HIDE_KEYBOARD_WAIT_TIME = 100; const INPUT_KEYS_WAIT_TIME = 100; @@ -47,15 +47,15 @@ helpers.dismissKeyguard = async function (driver, adb) { await sleep(HIDE_KEYBOARD_WAIT_TIME); } // dismiss notifications - logger.info("Dismiss notifications from unlock view"); - await adb.shell(["service", "call", "notification", "1"]); + logger.info('Dismiss notifications from unlock view'); + await adb.shell(['service', 'call', 'notification', '1']); await adb.back(); if (await adb.getApiLevel() > 21) { - logger.info("Trying to dismiss keyguard"); - await adb.shell(["wm", "dismiss-keyguard"]); + logger.info('Trying to dismiss keyguard'); + await adb.shell(['wm', 'dismiss-keyguard']); return; } - logger.info("Swiping up to dismiss keyguard"); + logger.info('Swiping up to dismiss keyguard'); await helpers.swipeUp(driver); }; @@ -73,7 +73,7 @@ helpers.swipeUp = async function (driver) { }; helpers.encodePassword = function (key) { - return key.replace(/\s/ig, "%s"); + return key.replace(/\s/ig, '%s'); }; helpers.stringKeyToArr = function (key) { @@ -82,7 +82,7 @@ helpers.stringKeyToArr = function (key) { helpers.fingerprintUnlock = async function (adb, driver, capabilities) { if (await adb.getApiLevel() < 23) { - throw new Error("Fingerprint unlock only works for Android 6+ emulators"); + throw new Error('Fingerprint unlock only works for Android 6+ emulators'); } await adb.fingerprint(capabilities.unlockKey); await sleep(UNLOCK_WAIT_TIME); @@ -93,13 +93,13 @@ helpers.pinUnlock = async function (adb, driver, capabilities) { await helpers.dismissKeyguard(driver, adb); let keys = helpers.stringKeyToArr(capabilities.unlockKey); if (await adb.getApiLevel() >= 21) { - let els = await driver.findElOrEls("id", "com.android.systemui:id/digit_text", true); + let els = await driver.findElOrEls('id', 'com.android.systemui:id/digit_text', true); if (_.isEmpty(els)) { - throw new Error("Error finding unlock pin buttons!"); + throw new Error('Error finding unlock pin buttons!'); } let pins = {}; for (let el of els) { - let text = await driver.getAttribute("text", util.unwrapElement(el)); + let text = await driver.getAttribute('text', util.unwrapElement(el)); pins[text] = el; } for (let pin of keys) { @@ -128,10 +128,10 @@ helpers.passwordUnlock = async function (adb, driver, capabilities) { // Replace blank spaces with %s key = helpers.encodePassword(key); // Why adb ? It was less flaky - await adb.shell(["input", "text", key]); + await adb.shell(['input', 'text', key]); // Why sleeps ? Avoid some flakyness waiting for the input to receive the keys await sleep(INPUT_KEYS_WAIT_TIME); - await adb.shell(["input", "keyevent", KEYCODE_NUMPAD_ENTER]); + await adb.shell(['input', 'keyevent', KEYCODE_NUMPAD_ENTER]); // Waits a bit for the device to be unlocked await sleep(UNLOCK_WAIT_TIME); }; @@ -210,7 +210,7 @@ helpers.patternUnlock = async function (adb, driver, capabilities) { using the parent view bounds and math. */ let apiLevel = await adb.getApiLevel(); - let el = await driver.findElOrEls("id", + let el = await driver.findElOrEls('id', `com.android.${apiLevel >= 21 ? 'systemui' : 'keyguard'}:id/lockPatternView`, false ); diff --git a/lib/webview-helpers.js b/lib/webview-helpers.js index ed4d6f735..b67c7f81b 100644 --- a/lib/webview-helpers.js +++ b/lib/webview-helpers.js @@ -2,13 +2,13 @@ import _ from 'lodash'; import logger from './logger'; import { asyncmap } from 'asyncbox'; -const NATIVE_WIN = "NATIVE_APP"; -const WEBVIEW_WIN = "WEBVIEW"; +const NATIVE_WIN = 'NATIVE_APP'; +const WEBVIEW_WIN = 'WEBVIEW'; const WEBVIEW_BASE = `${WEBVIEW_WIN}_`; const WEBVIEW_REGEXP = new RegExp(`@?webview_devtools_remote_(\\d+)`); const WEBVIEW_PID_REGEXP = new RegExp(`${WEBVIEW_BASE}(\\d+)`); -const CHROMIUM_WIN = "CHROMIUM"; -const CROSSWALK_SOCKET_SUFFIX = "_devtools_remote"; +const CHROMIUM_WIN = 'CHROMIUM'; +const CROSSWALK_SOCKET_SUFFIX = '_devtools_remote'; const CROSSWALK_REGEXP_STRING = `(\\S*)${CROSSWALK_SOCKET_SUFFIX}`; const CROSSWALK_REGEXP = new RegExp(`@${CROSSWALK_REGEXP_STRING}`); const CROSSWALK_PROCESS_REGEXP = new RegExp(WEBVIEW_BASE + CROSSWALK_REGEXP_STRING); @@ -24,13 +24,13 @@ let helpers = {}; // TODO: some of this function belongs in appium-adb async function webviewsFromProcs (adb, deviceSocket) { let webviews = []; - let out = await adb.shell(["cat", "/proc/net/unix"]); - for (let line of out.split("\n")) { + let out = await adb.shell(['cat', '/proc/net/unix']); + for (let line of out.split('\n')) { line = line.trim(); if (deviceSocket) { if (line.indexOf(`@${deviceSocket}`) === line.length - deviceSocket.length - 1) { - if (deviceSocket === "chrome_devtools_remote") { + if (deviceSocket === 'chrome_devtools_remote') { webviews.push(CHROMIUM_WIN); continue; } @@ -77,9 +77,9 @@ helpers.procFromWebview = async function (adb, webview) { } pid = pid[0]; logger.debug(`${webview} mapped to pid ${pid}`); - logger.debug("Getting process name for webview"); - let out = await adb.shell("ps"); - let pkg = "unknown"; + logger.debug('Getting process name for webview'); + let out = await adb.shell('ps'); + let pkg = 'unknown'; let lines = out.split(/\r?\n/); /* Output of ps is like: @@ -114,7 +114,7 @@ helpers.procFromWebview = async function (adb, webview) { // limits the webview possibilities to the one running on the Chromium devtools // socket we're interested in (see note on webviewsFromProcs) helpers.getWebviews = async function (adb, deviceSocket) { - logger.debug("Getting a list of available webviews"); + logger.debug('Getting a list of available webviews'); let webviews = await webviewsFromProcs(adb, deviceSocket); if (deviceSocket) { @@ -142,7 +142,7 @@ helpers.decorateChromeOptions = function (caps, opts, deviceId) { caps.chromeOptions[opt] = val; } else { logger.warn(`Cannot pass option ${caps.chromeOptions[opt]} because ` + - "Appium needs it to make chromeDriver work"); + 'Appium needs it to make chromeDriver work'); } } } diff --git a/test/functional/bootstrap/bootstrap-e2e-specs.js b/test/functional/bootstrap/bootstrap-e2e-specs.js index 8fea7b309..6b04d14be 100644 --- a/test/functional/bootstrap/bootstrap-e2e-specs.js +++ b/test/functional/bootstrap/bootstrap-e2e-specs.js @@ -38,20 +38,20 @@ describe('Android Bootstrap', function () { after(async function () { await androidBootstrap.shutdown(); }); - it("sendAction should work", async function () { + it('sendAction should work', async function () { (await androidBootstrap.sendAction('wake')).should.equal(true); }); - it("sendCommand should work", async function () { + it('sendCommand should work', async function () { (await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'getDataDir'})).should - .equal("/data"); + .equal('/data'); }); - it("sendCommand should correctly throw error", async function () { + it('sendCommand should correctly throw error', async function () { await androidBootstrap.sendCommand(COMMAND_TYPES.ACTION, {action: 'unknown'}).should .eventually.be.rejectedWith(errors.UnknownCommandError); }); - it("should cancel onUnexpectedShutdown promise on unexpected uiAutomator shutdown", async function () { + it('should cancel onUnexpectedShutdown promise on unexpected uiAutomator shutdown', async function () { await androidBootstrap.sendCommand(COMMAND_TYPES.SHUTDOWN); await androidBootstrap.onUnexpectedShutdown.should.eventually - .be.rejectedWith("UiAUtomator shut down unexpectedly"); + .be.rejectedWith('UiAUtomator shut down unexpectedly'); }); }); diff --git a/test/functional/chrome-e2e-specs.js b/test/functional/chrome-e2e-specs.js index fd724daa0..c083341a8 100644 --- a/test/functional/chrome-e2e-specs.js +++ b/test/functional/chrome-e2e-specs.js @@ -12,9 +12,9 @@ chai.use(chaiAsPromised); const avd = process.env.ANDROID_25_AVD || 'Nexus_5_API_25'; const capabilities = _.defaults({ avd, - platformVersion: "7.1", + platformVersion: '7.1', chromeOptions: { - args: ["--no-first-run"] + args: ['--no-first-run'] } }, CHROME_CAPS); @@ -33,6 +33,6 @@ describe('createSession', function () { it('should start chrome and dismiss the welcome dialog', async function () { await driver.createSession(capabilities); let appActivity = await driver.getCurrentActivity(); - appActivity.should.not.equal("org.chromium.chrome.browser.firstrun.FirstRunActivity"); + appActivity.should.not.equal('org.chromium.chrome.browser.firstrun.FirstRunActivity'); }); }); diff --git a/test/functional/commands/basic/attribute-e2e-specs.js b/test/functional/commands/basic/attribute-e2e-specs.js index 5a7a4cce8..18f28bcf8 100644 --- a/test/functional/commands/basic/attribute-e2e-specs.js +++ b/test/functional/commands/basic/attribute-e2e-specs.js @@ -37,7 +37,7 @@ describe('apidemo - attributes', function () { await driver.back(); }); it('should be able to find content description attribute', async function () { - await driver.getAttribute('contentDescription', animationEl).should.eventually.become("Animation"); + await driver.getAttribute('contentDescription', animationEl).should.eventually.become('Animation'); }); it('should be able to find displayed attribute', async function () { await driver.getAttribute('displayed', animationEl).should.eventually.become('true'); diff --git a/test/functional/commands/find/by-xpath-e2e-specs.js b/test/functional/commands/find/by-xpath-e2e-specs.js index a5d39c48e..b5260ac31 100644 --- a/test/functional/commands/find/by-xpath-e2e-specs.js +++ b/test/functional/commands/find/by-xpath-e2e-specs.js @@ -8,7 +8,7 @@ chai.should(); chai.use(chaiAsPromised); const atv = 'android.widget.TextView'; -const f = "android.widget.FrameLayout"; +const f = 'android.widget.FrameLayout'; describe('Find - xpath', function () { let driver; @@ -45,7 +45,7 @@ describe('Find - xpath', function () { it('should find the last element', async function () { let el = await driver.findElement('xpath', `(//${atv})[last()]`); let text = await driver.getText(el.ELEMENT); - ["OS", "Text", "Views", "Preference"].should.include(text); + ['OS', 'Text', 'Views', 'Preference'].should.include(text); }); // TODO: Doesn't work on CI. Works locally on API_LEVEL 23 diff --git a/test/functional/commands/geo-location-e2e-specs.js b/test/functional/commands/geo-location-e2e-specs.js index 0f4089830..c01be2cdb 100644 --- a/test/functional/commands/geo-location-e2e-specs.js +++ b/test/functional/commands/geo-location-e2e-specs.js @@ -8,7 +8,7 @@ import DEFAULT_CAPS from '../desired'; chai.should(); chai.use(chaiAsPromised); -describe.skip("geo-location", function () { +describe.skip('geo-location', function () { let driver; before(async function () { driver = new AndroidDriver(); diff --git a/test/functional/commands/keyboard/keyboard-e2e-specs.js b/test/functional/commands/keyboard/keyboard-e2e-specs.js index 98424330c..d40faace3 100644 --- a/test/functional/commands/keyboard/keyboard-e2e-specs.js +++ b/test/functional/commands/keyboard/keyboard-e2e-specs.js @@ -30,7 +30,7 @@ const defaultUnicodeCaps = _.defaults({ function deSamsungify (text) { // For samsung S5 text is appended with ". Editing." - return text.replace(". Editing.", ""); + return text.replace('. Editing.', ''); } async function getElement (driver, className) { diff --git a/test/functional/commands/touch/drag-e2e-specs.js b/test/functional/commands/touch/drag-e2e-specs.js index e64100d02..ad268704d 100644 --- a/test/functional/commands/touch/drag-e2e-specs.js +++ b/test/functional/commands/touch/drag-e2e-specs.js @@ -55,52 +55,52 @@ describe('apidemo - touch', function () { describe('performTouch', function () { this.retries(3); it('should drag by element', async function () { - let startEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_3"); - let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2"); + let startEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_3'); + let endEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_2'); let gestures = [ - {action: "longPress", options: {element: startEle.ELEMENT}}, - {action: "moveTo", options: {element: endEle.ELEMENT}}, - {action: "release", options: {}} + {action: 'longPress', options: {element: startEle.ELEMENT}}, + {action: 'moveTo', options: {element: endEle.ELEMENT}}, + {action: 'release', options: {}} ]; await driver.performTouch(gestures); - let resultEle = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text"); - await driver.getText(resultEle.ELEMENT).should.eventually.equal("Dropped!"); + let resultEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_result_text'); + await driver.getText(resultEle.ELEMENT).should.eventually.equal('Dropped!'); }); it('should drag by element by offset', async function () { - let startEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_3"); - let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2"); + let startEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_3'); + let endEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_2'); let gestures = [ - {action: "longPress", options: {element: startEle.ELEMENT, x: 5, y: 5}}, - {action: "moveTo", options: {element: endEle.ELEMENT, x: 5, y: 5}}, - {action: "release", options: {}} + {action: 'longPress', options: {element: startEle.ELEMENT, x: 5, y: 5}}, + {action: 'moveTo', options: {element: endEle.ELEMENT, x: 5, y: 5}}, + {action: 'release', options: {}} ]; await driver.performTouch(gestures); await retryInterval(3, 500, async () => { - const el = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text"); + const el = await driver.findElement('id', 'io.appium.android.apis:id/drag_result_text'); (await driver.getText(el.ELEMENT)).should.eql('Dropped!'); }); }); it('should drag by absolute position', async function () { - let startEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_3"); + let startEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_3'); let startLoc = await driver.getLocationInView(startEle.ELEMENT); let startSize = await driver.getSize(startEle.ELEMENT); - let endEle = await driver.findElement("id", "io.appium.android.apis:id/drag_dot_2"); + let endEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_dot_2'); let endLoc = await driver.getLocationInView(endEle.ELEMENT); let endSize = await driver.getSize(endEle.ELEMENT); let gestures = [ - {action: "longPress", options: { + {action: 'longPress', options: { x: startLoc.x + (startSize.width / 2), y: startLoc.y + (startSize.height / 2) }}, - {action: "moveTo", options: { + {action: 'moveTo', options: { x: endLoc.x + (endSize.width / 2), y: endLoc.y + (endSize.height / 2) }}, - {action: "release", options: {}} + {action: 'release', options: {}} ]; await driver.performTouch(gestures); - let resultEle = await driver.findElement("id", "io.appium.android.apis:id/drag_result_text"); - await driver.getText(resultEle.ELEMENT).should.eventually.equal("Dropped!"); + let resultEle = await driver.findElement('id', 'io.appium.android.apis:id/drag_result_text'); + await driver.getText(resultEle.ELEMENT).should.eventually.equal('Dropped!'); }); }); }); diff --git a/test/functional/driver-e2e-specs.js b/test/functional/driver-e2e-specs.js index 0613eda75..1fd428dec 100644 --- a/test/functional/driver-e2e-specs.js +++ b/test/functional/driver-e2e-specs.js @@ -167,7 +167,7 @@ describe('close', function () { await driver.closeApp(); let appPackage = await driver.getCurrentPackage(); if (appPackage) { - appPackage.should.not.equal("io.appium.android.apis"); + appPackage.should.not.equal('io.appium.android.apis'); } }); }); diff --git a/test/functional/unlocker-e2e-specs.js b/test/functional/unlocker-e2e-specs.js index c0b4882de..855a50814 100644 --- a/test/functional/unlocker-e2e-specs.js +++ b/test/functional/unlocker-e2e-specs.js @@ -11,13 +11,13 @@ let defaultCaps = _.defaults({ androidInstallTimeout: 90000 }, DEFAULT_CAPS); -const AVD_ANDROID_19_PIN_UNLOCK = "ANDROID_API_19_PIN_UNLOCK"; -const AVD_ANDROID_23_PIN_UNLOCK = "ANDROID_API_23_PIN_UNLOCK"; -const AVD_ANDROID_19_PASSWORD_UNLOCK = "ANDROID_API_19_PASSWORD_UNLOCK"; -const AVD_ANDROID_23_PASSWORD_UNLOCK = "ANDROID_API_23_PASSWORD_UNLOCK"; -const AVD_ANDROID_19_PATTERN_UNLOCK = "ANDROID_API_19_PATTERN_UNLOCK"; -const AVD_ANDROID_23_PATTERN_UNLOCK = "ANDROID_API_23_PATTERN_UNLOCK"; -const AVD_ANDROID_23_FINGERPRINT_UNLOCK = "ANDROID_API_23_FINGERPRINT_UNLOCK"; +const AVD_ANDROID_19_PIN_UNLOCK = 'ANDROID_API_19_PIN_UNLOCK'; +const AVD_ANDROID_23_PIN_UNLOCK = 'ANDROID_API_23_PIN_UNLOCK'; +const AVD_ANDROID_19_PASSWORD_UNLOCK = 'ANDROID_API_19_PASSWORD_UNLOCK'; +const AVD_ANDROID_23_PASSWORD_UNLOCK = 'ANDROID_API_23_PASSWORD_UNLOCK'; +const AVD_ANDROID_19_PATTERN_UNLOCK = 'ANDROID_API_19_PATTERN_UNLOCK'; +const AVD_ANDROID_23_PATTERN_UNLOCK = 'ANDROID_API_23_PATTERN_UNLOCK'; +const AVD_ANDROID_23_FINGERPRINT_UNLOCK = 'ANDROID_API_23_FINGERPRINT_UNLOCK'; describe('unlock tests', function () { let driver; @@ -30,43 +30,43 @@ describe('unlock tests', function () { await driver.deleteSession(); }); it('should unlock an Android 19 device using a PIN', async function () { - let caps = _.extend(defaultCaps, {unlockType: "pin", unlockKey: "1111", avd: AVD_ANDROID_19_PIN_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'pin', unlockKey: '1111', avd: AVD_ANDROID_19_PIN_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 23 device using a PIN', async function () { - let caps = _.extend(defaultCaps, {unlockType: "pin", unlockKey: "1111", avd: AVD_ANDROID_23_PIN_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'pin', unlockKey: '1111', avd: AVD_ANDROID_23_PIN_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 19 device using a PASSWORD', async function () { - let caps = _.extend(defaultCaps, {unlockType: "password", unlockKey: "appium", avd: AVD_ANDROID_19_PASSWORD_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'password', unlockKey: 'appium', avd: AVD_ANDROID_19_PASSWORD_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 23 device using a PASSWORD', async function () { - let caps = _.extend(defaultCaps, {unlockType: "password", unlockKey: "appium", avd: AVD_ANDROID_23_PASSWORD_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'password', unlockKey: 'appium', avd: AVD_ANDROID_23_PASSWORD_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 19 device using a PATTERN', async function () { - let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_19_PATTERN_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'pattern', unlockKey: '729856143', avd: AVD_ANDROID_19_PATTERN_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 23 device using a PATTERN', async function () { - let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_23_PATTERN_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'pattern', unlockKey: '729856143', avd: AVD_ANDROID_23_PATTERN_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); }); it('should unlock an Android 23 device using FINGERPRINT', async function () { - let caps = _.extend(defaultCaps, {unlockType: "pattern", unlockKey: "729856143", avd: AVD_ANDROID_23_FINGERPRINT_UNLOCK}); + let caps = _.extend(defaultCaps, {unlockType: 'pattern', unlockKey: '729856143', avd: AVD_ANDROID_23_FINGERPRINT_UNLOCK}); await driver.createSession(caps); let isLock = await driver.adb.isScreenLocked(); isLock.should.equal(false); diff --git a/test/functional/webview-browser-tester-e2e-specs.js b/test/functional/webview-browser-tester-e2e-specs.js index 07693c148..56dd058d5 100644 --- a/test/functional/webview-browser-tester-e2e-specs.js +++ b/test/functional/webview-browser-tester-e2e-specs.js @@ -56,7 +56,7 @@ describe('Android 7 Webview Browser tester', function () { await driver.setUrl(`http://${HOST}:${PORT}/test/guinea-pig`); // make sure we are in the right context - await driver.getCurrentContext().should.eventually.eql("CHROMIUM"); + await driver.getCurrentContext().should.eventually.eql('CHROMIUM'); let el = await driver.findElement('id', 'i am a link'); await driver.click(el.ELEMENT); diff --git a/test/unit/android-helper-specs.js b/test/unit/android-helper-specs.js index 7a28ca579..54a3c270d 100644 --- a/test/unit/android-helper-specs.js +++ b/test/unit/android-helper-specs.js @@ -12,7 +12,7 @@ import B from 'bluebird'; const should = chai.should(); -const REMOTE_TEMP_PATH = "/data/local/tmp"; +const REMOTE_TEMP_PATH = '/data/local/tmp'; chai.use(chaiAsPromised); @@ -22,7 +22,7 @@ describe('Android Helpers', function () { it('should correctly parse java version', function () { helpers.parseJavaVersion(`java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b27)`).should - .be.equal("1.8.0_40"); + .be.equal('1.8.0_40'); }); it('should return null if it cannot parse java verstion', function () { should.not.exist(helpers.parseJavaVersion('foo bar')); @@ -47,10 +47,10 @@ describe('Android Helpers', function () { }); })); describe('prepareEmulator', withMocks({adb, helpers}, (mocks) => { - const opts = {avd: "foo@bar", avdArgs: "", language: "en", locale: "us"}; + const opts = {avd: 'foo@bar', avdArgs: '', language: 'en', locale: 'us'}; it('should not launch avd if one is already running', async function () { mocks.adb.expects('getRunningAVD').withExactArgs('foobar') - .returns("foo"); + .returns('foo'); mocks.adb.expects('launchAVD').never(); mocks.adb.expects('killEmulator').never(); await helpers.prepareEmulator(adb, opts); @@ -61,12 +61,12 @@ describe('Android Helpers', function () { .returns(null); mocks.adb.expects('launchAVD').withExactArgs('foo@bar', '', 'en', 'us', undefined, undefined) - .returns(""); + .returns(''); await helpers.prepareEmulator(adb, opts); mocks.adb.verify(); }); it('should kill emulator if avdArgs contains -wipe-data', async function () { - const opts = {avd: "foo@bar", avdArgs: "-wipe-data"}; + const opts = {avd: 'foo@bar', avdArgs: '-wipe-data'}; mocks.adb.expects('getRunningAVD').withExactArgs('foobar').returns('foo'); mocks.adb.expects('killEmulator').withExactArgs('foobar').once(); mocks.adb.expects('launchAVD').once(); @@ -289,10 +289,10 @@ describe('Android Helpers', function () { keyPassword: 'keyPassword', }); ADB.createADB.calledWithExactly({ - javaVersion: "1.7", - adbPort: "222", + javaVersion: '1.7', + adbPort: '222', suppressKillServer: true, - remoteAdbHost: "remote_host", + remoteAdbHost: 'remote_host', clearDeviceLogsOnStart: true, adbExecTimeout: 50, useKeystore: true, @@ -301,8 +301,8 @@ describe('Android Helpers', function () { keyAlias: 'keyAlias', keyPassword: 'keyPassword', }).should.be.true; - curDeviceId.should.equal("111222"); - emulatorPort.should.equal("111"); + curDeviceId.should.equal('111222'); + emulatorPort.should.equal('111'); }); it('should not set emulator port if emPort is undefined', async function () { emulatorPort = 5555; @@ -319,27 +319,27 @@ describe('Android Helpers', function () { it('should return when appPackage & appActivity are already present', async function () { mocks.adb.expects('packageAndLaunchActivityFromManifest').never(); await helpers.getLaunchInfo(adb, { - app: "foo", - appPackage: "bar", - appActivity: "act", + app: 'foo', + appPackage: 'bar', + appActivity: 'act', }); mocks.adb.verify(); }); it('should return when all parameters are already present', async function () { mocks.adb.expects('packageAndLaunchActivityFromManifest').never(); - await helpers.getLaunchInfo(adb, {app: "foo", appPackage: "bar", appWaitPackage: "*", appActivity: "app.activity", appWaitActivity: "app.nameA,app.nameB"}); + await helpers.getLaunchInfo(adb, {app: 'foo', appPackage: 'bar', appWaitPackage: '*', appActivity: 'app.activity', appWaitActivity: 'app.nameA,app.nameB'}); mocks.adb.verify(); }); it('should print warn when all parameters are already present but the format is odd', async function () { // It only prints warn message mocks.adb.expects('packageAndLaunchActivityFromManifest').never(); - await helpers.getLaunchInfo(adb, {app: "foo", appPackage: "bar ", appWaitPackage: "*", appActivity: "a_act", appWaitActivity: ". "}); + await helpers.getLaunchInfo(adb, {app: 'foo', appPackage: 'bar ', appWaitPackage: '*', appActivity: 'a_act', appWaitActivity: '. '}); mocks.adb.verify(); }); it('should print warn when appPackage & appActivity are already present but the format is odd', async function () { // It only prints warn message mocks.adb.expects('packageAndLaunchActivityFromManifest').never(); - await helpers.getLaunchInfo(adb, {app: "foo", appPackage: "bar", appActivity: "a_act "}); + await helpers.getLaunchInfo(adb, {app: 'foo', appPackage: 'bar', appActivity: 'a_act '}); mocks.adb.verify(); }); it('should return package and launch activity from manifest', async function () { @@ -351,7 +351,7 @@ describe('Android Helpers', function () { appActivity: 'ack', appWaitActivity: 'ack', }; - (await helpers.getLaunchInfo(adb, {app: "foo"})).should.deep + (await helpers.getLaunchInfo(adb, {app: 'foo'})).should.deep .equal(result); mocks.adb.verify(); }); @@ -615,7 +615,7 @@ describe('Android Helpers', function () { it('should raise an error on undefined unlockKey when unlockType is defined', async function () { mocks.adb.expects('isScreenLocked').once().returns(true); mocks.unlocker.expects('isValidKey').once(); - await helpers.unlock(helpers, adb, {unlockType: "pin"}).should.be.rejectedWith('unlockKey'); + await helpers.unlock(helpers, adb, {unlockType: 'pin'}).should.be.rejectedWith('unlockKey'); mocks.adb.verify(); mocks.unlocker.verify(); mocks.helpers.verify(); @@ -624,7 +624,7 @@ describe('Android Helpers', function () { mocks.adb.expects('isScreenLocked').onCall(0).returns(true); mocks.adb.expects('isScreenLocked').returns(false); mocks.unlocker.expects('pinUnlock').once(); - await helpers.unlock(helpers, adb, {unlockType: "pin", unlockKey: "1111"}); + await helpers.unlock(helpers, adb, {unlockType: 'pin', unlockKey: '1111'}); mocks.adb.verify(); mocks.helpers.verify(); }); @@ -632,7 +632,7 @@ describe('Android Helpers', function () { mocks.adb.expects('isScreenLocked').onCall(0).returns(true); mocks.adb.expects('isScreenLocked').returns(false); mocks.unlocker.expects('passwordUnlock').once(); - await helpers.unlock(helpers, adb, {unlockType: "password", unlockKey: "appium"}); + await helpers.unlock(helpers, adb, {unlockType: 'password', unlockKey: 'appium'}); mocks.adb.verify(); mocks.helpers.verify(); }); @@ -640,7 +640,7 @@ describe('Android Helpers', function () { mocks.adb.expects('isScreenLocked').onCall(0).returns(true); mocks.adb.expects('isScreenLocked').returns(false); mocks.unlocker.expects('patternUnlock').once(); - await helpers.unlock(helpers, adb, {unlockType: "pattern", unlockKey: "123456789"}); + await helpers.unlock(helpers, adb, {unlockType: 'pattern', unlockKey: '123456789'}); mocks.adb.verify(); mocks.helpers.verify(); }); @@ -648,7 +648,7 @@ describe('Android Helpers', function () { mocks.adb.expects('isScreenLocked').onCall(0).returns(true); mocks.adb.expects('isScreenLocked').returns(false); mocks.unlocker.expects('fingerprintUnlock').once(); - await helpers.unlock(helpers, adb, {unlockType: "fingerprint", unlockKey: "1111"}); + await helpers.unlock(helpers, adb, {unlockType: 'fingerprint', unlockKey: '1111'}); mocks.adb.verify(); mocks.unlocker.verify(); }); @@ -656,14 +656,14 @@ describe('Android Helpers', function () { mocks.adb.expects('isScreenLocked').onCall(0).returns(true); mocks.adb.expects('isScreenLocked').returns(false); mocks.adb.expects('getApiLevel').once().returns(21); - await helpers.unlock(helpers, adb, {unlockType: "fingerprint", unlockKey: "1111"}).should.eventually + await helpers.unlock(helpers, adb, {unlockType: 'fingerprint', unlockKey: '1111'}).should.eventually .be.rejectedWith('Fingerprint'); mocks.helpers.verify(); }); })); describe('initDevice', withMocks({helpers, adb}, (mocks) => { it('should init device', async function () { - const opts = {language: "en", locale: "us", localeScript: 'Script'}; + const opts = {language: 'en', locale: 'us', localeScript: 'Script'}; mocks.adb.expects('waitForDevice').once(); mocks.adb.expects('startLogcat').once(); mocks.helpers.expects('pushSettingsApp').once(); @@ -685,7 +685,7 @@ describe('Android Helpers', function () { mocks.adb.verify(); }); it('should init device with either locale or language', async function () { - const opts = {language: "en"}; + const opts = {language: 'en'}; mocks.adb.expects('waitForDevice').once(); mocks.adb.expects('startLogcat').once(); mocks.helpers.expects('pushSettingsApp').once(); @@ -696,7 +696,7 @@ describe('Android Helpers', function () { mocks.adb.verify(); }); it('should not install mock location on emulator', async function () { - const opts = {avd: "avd"}; + const opts = {avd: 'avd'}; mocks.adb.expects('waitForDevice').once(); mocks.adb.expects('startLogcat').once(); mocks.helpers.expects('pushSettingsApp').once(); @@ -713,8 +713,8 @@ describe('Android Helpers', function () { mocks.helpers.expects('pushSettingsApp').once(); mocks.helpers.expects('ensureDeviceLocale').never(); mocks.helpers.expects('setMockLocationApp').once(); - mocks.helpers.expects('initUnicodeKeyboard').withExactArgs(adb).once().returns("defaultIME"); - await helpers.initDevice(adb, opts).should.become("defaultIME"); + mocks.helpers.expects('initUnicodeKeyboard').withExactArgs(adb).once().returns('defaultIME'); + await helpers.initDevice(adb, opts).should.become('defaultIME'); mocks.helpers.verify(); mocks.adb.verify(); }); @@ -731,7 +731,7 @@ describe('Android Helpers', function () { mocks.adb.verify(); }); it('should not push unlock app if unlockType is defined', async function () { - const opts = {unlockType: "unlock_type"}; + const opts = {unlockType: 'unlock_type'}; mocks.adb.expects('waitForDevice').once(); mocks.adb.expects('startLogcat').once(); mocks.helpers.expects('pushSettingsApp').once(); diff --git a/test/unit/commands/context-specs.js b/test/unit/commands/context-specs.js index 18d773be0..ed17ec11f 100644 --- a/test/unit/commands/context-specs.js +++ b/test/unit/commands/context-specs.js @@ -291,9 +291,9 @@ describe('Context', function () { .should.be.equal('app_act'); }); it('should be able to set loggingPrefs capability', async function () { - let chromedriver = await setupNewChromedriver({pageLoadStrategy: "strategy"}); + let chromedriver = await setupNewChromedriver({pageLoadStrategy: 'strategy'}); chromedriver.start.getCall(0).args[0].pageLoadStrategy - .should.be.equal("strategy"); + .should.be.equal('strategy'); }); }); }); diff --git a/test/unit/commands/general-specs.js b/test/unit/commands/general-specs.js index eaa9e2fdd..5548f2cde 100644 --- a/test/unit/commands/general-specs.js +++ b/test/unit/commands/general-specs.js @@ -288,7 +288,7 @@ describe('General', function () { describe('getStrings', withMocks({helpers}, (mocks) => { it('should return app strings', async function () { driver.bootstrap.sendAction = () => { return ''; }; - mocks.helpers.expects("pushStrings") + mocks.helpers.expects('pushStrings') .returns({test: 'en_value'}); let strings = await driver.getStrings('en'); strings.test.should.equal('en_value'); diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index 6d275bcf2..d8625cda1 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -36,7 +36,7 @@ describe('driver', function () { it('should be rejected if isEmulator is false', function () { let driver = new AndroidDriver(); sandbox.stub(driver, 'isEmulator').returns(false); - driver.fingerprint(1111).should.eventually.be.rejectedWith("fingerprint method is only available for emulators"); + driver.fingerprint(1111).should.eventually.be.rejectedWith('fingerprint method is only available for emulators'); driver.isEmulator.calledOnce.should.be.true; }); }); @@ -44,7 +44,7 @@ describe('driver', function () { it('sendSMS should be rejected if isEmulator is false', function () { let driver = new AndroidDriver(); sandbox.stub(driver, 'isEmulator').returns(false); - driver.sendSMS(4509, "Hello Appium").should.eventually.be.rejectedWith("sendSMS method is only available for emulators"); + driver.sendSMS(4509, 'Hello Appium').should.eventually.be.rejectedWith('sendSMS method is only available for emulators'); driver.isEmulator.calledOnce.should.be.true; }); }); @@ -121,12 +121,12 @@ describe('driver', function () { sandbox.restore(); }); it('should verify device is an emulator', function () { - driver.opts.avd = "Nexus_5X_Api_23"; + driver.opts.avd = 'Nexus_5X_Api_23'; driver.isEmulator().should.equal(true); driver.opts.avd = undefined; - driver.opts.udid = "emulator-5554"; + driver.opts.udid = 'emulator-5554'; driver.isEmulator().should.equal(true); - driver.opts.udid = "01234567889"; + driver.opts.udid = '01234567889'; driver.isEmulator().should.equal(false); }); it('should get java version if none is provided', async function () { @@ -259,11 +259,11 @@ describe('driver', function () { driver.shouldDismissChromeWelcome().should.be.false; driver.opts = {chromeOptions: {args: []}}; driver.shouldDismissChromeWelcome().should.be.false; - driver.opts = {chromeOptions: {args: "--no-first-run"}}; + driver.opts = {chromeOptions: {args: '--no-first-run'}}; driver.shouldDismissChromeWelcome().should.be.false; - driver.opts = {chromeOptions: {args: ["--disable-dinosaur-easter-egg"]}}; + driver.opts = {chromeOptions: {args: ['--disable-dinosaur-easter-egg']}}; driver.shouldDismissChromeWelcome().should.be.false; - driver.opts = {chromeOptions: {args: ["--no-first-run"]}}; + driver.opts = {chromeOptions: {args: ['--no-first-run']}}; driver.shouldDismissChromeWelcome().should.be.true; }); }); @@ -273,28 +273,28 @@ describe('driver', function () { driver.caps = {}; }); it('should throw error if run with full reset', async function () { - driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: true}; + driver.opts = {appPackage: 'app.package', appActivity: 'act', fullReset: true}; await driver.initAUT().should.be.rejectedWith(/Full reset requires an app capability/); }); it('should reset if run with fast reset', async function () { - driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: false, fastReset: true}; - driver.adb = "mock_adb"; - mocks.helpers.expects("resetApp").withArgs("mock_adb"); + driver.opts = {appPackage: 'app.package', appActivity: 'act', fullReset: false, fastReset: true}; + driver.adb = 'mock_adb'; + mocks.helpers.expects('resetApp').withArgs('mock_adb'); await driver.initAUT(); mocks.helpers.verify(); }); it('should keep data if run without reset', async function () { - driver.opts = {appPackage: "app.package", appActivity: "act", fullReset: false, fastReset: false}; - mocks.helpers.expects("resetApp").never(); + driver.opts = {appPackage: 'app.package', appActivity: 'act', fullReset: false, fastReset: false}; + mocks.helpers.expects('resetApp').never(); await driver.initAUT(); mocks.helpers.verify(); }); it('should install "otherApps" if set in capabilities', async function () { - const otherApps = ["http://URL_FOR/fake/app.apk"]; - const tempApps = ["/path/to/fake/app.apk"]; + const otherApps = ['http://URL_FOR/fake/app.apk']; + const tempApps = ['/path/to/fake/app.apk']; driver.opts = { - appPackage: "app.package", - appActivity: "act", + appPackage: 'app.package', + appActivity: 'act', fullReset: false, fastReset: false, otherApps: `["${otherApps[0]}"]`, @@ -302,7 +302,7 @@ describe('driver', function () { sandbox.stub(driver.helpers, 'configureApp') .withArgs(otherApps[0], '.apk') .returns(tempApps[0]); - mocks.helpers.expects("installOtherApks").once().withArgs(tempApps, driver.adb, driver.opts); + mocks.helpers.expects('installOtherApks').once().withArgs(tempApps, driver.adb, driver.opts); await driver.initAUT(); mocks.helpers.verify(); }); @@ -471,7 +471,7 @@ describe('driver', function () { it('should call dismissChromeWelcome', async function () { driver.opts.browserName = 'Chrome'; driver.opts.chromeOptions = { - "args": ["--no-first-run"] + 'args': ['--no-first-run'] }; await driver.startChromeSession(); driver.dismissChromeWelcome.calledOnce.should.be.true; diff --git a/test/unit/unlock-helper-specs.js b/test/unit/unlock-helper-specs.js index f81cdf5cc..f4bfc887d 100644 --- a/test/unit/unlock-helper-specs.js +++ b/test/unit/unlock-helper-specs.js @@ -7,7 +7,7 @@ import AndroidDriver from '../../lib/driver'; import * as asyncbox from 'asyncbox'; import ADB from 'appium-adb'; -const KEYCODE_NUMPAD_ENTER = "66"; +const KEYCODE_NUMPAD_ENTER = '66'; const INPUT_KEYS_WAIT_TIME = 100; const HIDE_KEYBOARD_WAIT_TIME = 100; const UNLOCK_WAIT_TIME = 100; @@ -77,7 +77,7 @@ describe('Unlock Helpers', function () { it('should dismiss notifications and dissmiss keyguard via swipping up', async function () { mocks.driver.expects('isKeyboardShown').returns(false); mocks.adb.expects('shell') - .withExactArgs(["service", "call", "notification", "1"]).once(); + .withExactArgs(['service', 'call', 'notification', '1']).once(); mocks.adb.expects('back').once(); mocks.adb.expects('getApiLevel').returns(21); mocks.helpers.expects('swipeUp').withExactArgs(driver).once(); @@ -91,7 +91,7 @@ describe('Unlock Helpers', function () { mocks.adb.expects('shell').onCall(0).returns(''); mocks.adb.expects('back').once(); mocks.adb.expects('getApiLevel').returns(22); - mocks.adb.expects('shell').withExactArgs(["wm", "dismiss-keyguard"]).once(); + mocks.adb.expects('shell').withExactArgs(['wm', 'dismiss-keyguard']).once(); mocks.helpers.expects('swipeUp').never(); await helpers.dismissKeyguard(driver, adb); mocks.driver.verify(); @@ -115,8 +115,8 @@ describe('Unlock Helpers', function () { })); describe('encodePassword', function () { it('should verify the password with blank space is encoded', function () { - helpers.encodePassword('a p p i u m').should.equal("a%sp%sp%si%su%sm"); - helpers.encodePassword(' ').should.equal("%s%s%s"); + helpers.encodePassword('a p p i u m').should.equal('a%sp%sp%si%su%sm'); + helpers.encodePassword(' ').should.equal('%s%s%s'); }); }); describe('stringKeyToArr', function () { @@ -163,7 +163,7 @@ describe('Unlock Helpers', function () { mocks.helpers.expects('stringKeyToArr').returns(keys); mocks.adb.expects('getApiLevel').returns(21); mocks.driver.expects('findElOrEls') - .withExactArgs("id", "com.android.systemui:id/digit_text", true) + .withExactArgs('id', 'com.android.systemui:id/digit_text', true) .returns(els); mocks.driver.expects('findElOrEls') .withExactArgs('xpath', "//*[contains(@resource-id, 'id/key_enter')]", false) @@ -195,7 +195,7 @@ describe('Unlock Helpers', function () { mocks.adb.expects('getApiLevel').returns(20); for (let pin of keys) { mocks.driver.expects('findElOrEls') - .withExactArgs("id", `com.android.keyguard:id/key${pin}`, false) + .withExactArgs('id', `com.android.keyguard:id/key${pin}`, false) .returns({ELEMENT: parseInt(pin, 10)}); } mocks.driver.expects('findElOrEls') @@ -287,7 +287,7 @@ describe('Unlock Helpers', function () { }); describe('getPatternActions', function () { it('should generate press, moveTo, relase gesture scheme to unlock by pattern', function () { - let keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]; + let keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9']; let actions = helpers.getPatternActions(keys, {x: 0, y: 0}, 1); actions.map((action, i) => { if (i === 0) { @@ -300,7 +300,7 @@ describe('Unlock Helpers', function () { }); }); it('should verify pattern gestures moves to non consecutives pins', function () { - let keys = ["7", "2", "9", "8", "5", "6", "1", "4", "3"]; + let keys = ['7', '2', '9', '8', '5', '6', '1', '4', '3']; let actions = helpers.getPatternActions(keys, {x: 0, y: 0}, 1); // Move from pin 7 to pin 2 actions[1].options.x.should.equal(1);