appium-mac2-driver 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/build/lib/commands/app-management.js.map +1 -0
- package/build/lib/commands/applescript.js.map +1 -0
- package/build/lib/commands/execute.js.map +1 -0
- package/build/lib/commands/find.js.map +1 -0
- package/build/lib/commands/gestures.js.map +1 -0
- package/build/lib/commands/index.js.map +1 -0
- package/build/lib/commands/record-screen.js.map +1 -0
- package/build/lib/commands/screenshots.js.map +1 -0
- package/build/lib/commands/source.js.map +1 -0
- package/build/lib/desired-caps.js.map +1 -0
- package/build/lib/driver.js.map +1 -0
- package/build/lib/logger.js.map +1 -0
- package/build/lib/utils.js +7 -18
- package/build/lib/utils.js.map +1 -0
- package/build/lib/wda-mac.js.map +1 -0
- package/lib/utils.js +7 -15
- package/npm-shrinkwrap.json +773 -822
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,6 +11,11 @@ This is Appium driver for automating macOS applications using Apple's [XCTest](h
|
|
|
11
11
|
The driver operates in scope of [W3C WebDriver protocol](https://www.w3.org/TR/webdriver/) with several custom extensions to cover operating-system specific scenarios.
|
|
12
12
|
The original idea and parts of the source code are borrowed from the Facebook's [WebDriverAgent](https://github.com/facebookarchive/WebDriverAgent) project.
|
|
13
13
|
|
|
14
|
+
> **Note**
|
|
15
|
+
>
|
|
16
|
+
> Since version 1.0.0 Mac2 driver has dropped the support of Appium 1, and is only compatible to Appium 2. Use the `appium driver install mac2`
|
|
17
|
+
> command to add it to your Appium 2 dist.
|
|
18
|
+
|
|
14
19
|
|
|
15
20
|
## Requirements
|
|
16
21
|
|
|
@@ -19,10 +24,8 @@ On top of standard Appium requirements Mac2 driver also expects the following pr
|
|
|
19
24
|
- macOS 10.15 or later
|
|
20
25
|
- Xcode 12 or later should be installed
|
|
21
26
|
- Xcode Helper app should be enabled for Accessibility access. The app itself could be usually found at `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/Xcode Helper.app`. In order to enable Accessibility access for it simply open the parent folder in Finder: `open /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/` and drag & drop the `Xcode Helper` app to `Security & Privacy -> Privacy -> Accessibility` list of your `System Preferences`. This action must only be done once.
|
|
22
|
-
-
|
|
23
|
-
|
|
27
|
+
- `testmanagerd` proccess requires UIAutomation authentication since macOS 12. `automationmodetool enable-automationmode-without-authentication` command may help to disable it. This may be particularly useful in CI environments. [Apple forum thread](https://developer.apple.com/forums/thread/693850).
|
|
24
28
|
|
|
25
|
-
`testmanagerd` procccess requires UIAutomation authentication since macOS 12. `automationmodetool enable-automationmode-without-authentication` command may help to disable it. It may help especially CI environment. [apple forum](https://developer.apple.com/forums/thread/693850).
|
|
26
29
|
|
|
27
30
|
## Capabilities
|
|
28
31
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-management.js","names":["commands","macosLaunchApp","opts","bundleId","environment","wda","proxy","command","arguments","macosActivateApp","macosTerminateApp","macosQueryAppState"],"sources":["../../../lib/commands/app-management.js"],"sourcesContent":["const commands = {};\n\n/**\n * @typedef {Object} LaunchAppOptions\n * @property {!string} bundleId bundle identifier of the app to be launched\n * or activated\n * @property {?Array<string>} arguments the list of command line arguments\n * for the app to be be launched with. This parameter is ignored if the app\n * is already running.\n * @property {Object} environment environment variables mapping. Custom\n * variables are added to the default process environment.\n */\n\n/**\n * Start an app with given bundle identifier or activates it\n * if the app is already running. An exception is thrown if the\n * app with the given identifier cannot be found.\n *\n * @param {LaunchAppOptions} opts\n */\ncommands.macosLaunchApp = async function macosLaunchApp (opts = {}) {\n const { bundleId, environment } = opts;\n return await this.wda.proxy.command('/wda/apps/launch', 'POST', {\n arguments: opts.arguments,\n environment,\n bundleId,\n });\n};\n\n/**\n * @typedef {Object} ActivateAppOptions\n * @property {!string} bundleId bundle identifier of the app to be activated\n */\n\n/**\n * Activate an app with given bundle identifier. An exception is thrown if the\n * app cannot be found or is not running.\n *\n * @param {ActivateAppOptions} opts\n */\ncommands.macosActivateApp = async function macosActivateApp (opts = {}) {\n const { bundleId } = opts;\n return await this.wda.proxy.command('/wda/apps/activate', 'POST', { bundleId });\n};\n\n/**\n * @typedef {Object} TerminateAppOptions\n * @property {!string} bundleId bundle identifier of the app to be terminated\n */\n\n/**\n * Terminate an app with given bundle identifier. An exception is thrown if the\n * app cannot be found.\n *\n * @param {TerminateAppOptions} opts\n * @returns {boolean} `true` if the app was running and has been successfully terminated.\n * `false` if the app was not running before.\n */\ncommands.macosTerminateApp = async function macosTerminateApp (opts = {}) {\n const { bundleId } = opts;\n return await this.wda.proxy.command('/wda/apps/terminate', 'POST', { bundleId });\n};\n\n/**\n * @typedef {Object} QueryAppStateOptions\n * @property {!string} bundleId bundle identifier of the app whose state should be queried\n */\n\n/**\n * Query an app state with given bundle identifier. An exception is thrown if the\n * app cannot be found.\n *\n * @param {QueryAppStateOptions} opts\n * @returns {number} The application state code. See\n * https://developer.apple.com/documentation/xctest/xcuiapplicationstate?language=objc\n * for more details\n */\ncommands.macosQueryAppState = async function macosQueryAppState (opts = {}) {\n const { bundleId } = opts;\n return await this.wda.proxy.command('/wda/apps/state', 'POST', { bundleId });\n};\n\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA,MAAMA,QAAQ,GAAG,EAAjB;;AAoBAA,QAAQ,CAACC,cAAT,GAA0B,eAAeA,cAAf,CAA+BC,IAAI,GAAG,EAAtC,EAA0C;EAClE,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA4BF,IAAlC;EACA,OAAO,MAAM,KAAKG,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuB,kBAAvB,EAA2C,MAA3C,EAAmD;IAC9DC,SAAS,EAAEN,IAAI,CAACM,SAD8C;IAE9DJ,WAF8D;IAG9DD;EAH8D,CAAnD,CAAb;AAKD,CAPD;;AAoBAH,QAAQ,CAACS,gBAAT,GAA4B,eAAeA,gBAAf,CAAiCP,IAAI,GAAG,EAAxC,EAA4C;EACtE,MAAM;IAAEC;EAAF,IAAeD,IAArB;EACA,OAAO,MAAM,KAAKG,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuB,oBAAvB,EAA6C,MAA7C,EAAqD;IAAEJ;EAAF,CAArD,CAAb;AACD,CAHD;;AAkBAH,QAAQ,CAACU,iBAAT,GAA6B,eAAeA,iBAAf,CAAkCR,IAAI,GAAG,EAAzC,EAA6C;EACxE,MAAM;IAAEC;EAAF,IAAeD,IAArB;EACA,OAAO,MAAM,KAAKG,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuB,qBAAvB,EAA8C,MAA9C,EAAsD;IAAEJ;EAAF,CAAtD,CAAb;AACD,CAHD;;AAmBAH,QAAQ,CAACW,kBAAT,GAA8B,eAAeA,kBAAf,CAAmCT,IAAI,GAAG,EAA1C,EAA8C;EAC1E,MAAM;IAAEC;EAAF,IAAeD,IAArB;EACA,OAAO,MAAM,KAAKG,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuB,iBAAvB,EAA0C,MAA1C,EAAkD;IAAEJ;EAAF,CAAlD,CAAb;AACD,CAHD;;eAKeH,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applescript.js","names":["OSASCRIPT","APPLE_SCRIPT_FEATURE","commands","macosExecAppleScript","opts","ensureFeatureEnabled","script","language","command","cwd","timeout","log","errorAndThrow","test","shouldRunScript","args","push","tmpRoot","tempDir","openDir","tmpScriptPath","path","resolve","fs","writeFile","info","util","quote","stdout","exec","e","Error","stderr","message","rimraf"],"sources":["../../../lib/commands/applescript.js"],"sourcesContent":["import { fs, tempDir, util } from 'appium/support';\nimport { exec } from 'teen_process';\nimport log from '../logger';\nimport path from 'path';\n\nconst OSASCRIPT = 'osascript';\nconst APPLE_SCRIPT_FEATURE = 'apple_script';\n\nconst commands = {};\n\n/**\n * @typedef {Object} ExecAppleScriptOptions\n * @property {?string} script A valid AppleScript to execute\n * @property {?string} language Overrides the scripting language. Basically, sets the value of `-l` command\n * line argument of `osascript` tool. If unset the AppleScript language is assumed.\n * @property {?string} command A valid AppleScript as a single command (no line breaks) to execute\n * @property {?number} timeout [20000] The number of seconds to wait until a long-running command is\n * finished. An error is thrown if the command is still running after this timeout expires.\n * @property {?string} cwd The path to an existing folder, which is going to be set as the\n * working directory for the command/script being executed.\n */\n\n/**\n * Executes the given AppleScript command or a whole script based on the\n * given options. Either of these options must be provided. If both are provided\n * then the `command` one gets the priority.\n * Note that AppleScript command cannot contain line breaks. Consider making it\n * to a script in such case.\n * Note that by default AppleScript engine blocks commands/scripts execution if your script\n * is trying to access some private entities, like cameras or the desktop screen\n * and no permissions to do it are given to the parent (for example, Appium or Terminal)\n * process in System Preferences -> Privacy list.\n *\n * @param {!ExecAppleScriptOptions} opts\n * @returns {string} The actual stdout of the given command/script\n * @throws {Error} If the exit code of the given command/script is not zero.\n * The actual stderr output is set to the error message value.\n */\ncommands.macosExecAppleScript = async function macosExecAppleScript (opts = {}) {\n this.ensureFeatureEnabled(APPLE_SCRIPT_FEATURE);\n\n const {\n script,\n language,\n command,\n cwd,\n timeout,\n } = opts;\n if (!script && !command) {\n log.errorAndThrow('AppleScript script/command must not be empty');\n }\n if (/\\n/.test(command)) {\n log.errorAndThrow('AppleScript commands cannot contain line breaks');\n }\n // 'command' has priority over 'script'\n const shouldRunScript = !command;\n\n const args = [];\n if (language) {\n args.push('-l', language);\n }\n let tmpRoot;\n try {\n if (shouldRunScript) {\n tmpRoot = await tempDir.openDir();\n const tmpScriptPath = path.resolve(tmpRoot, 'appium_script.scpt');\n await fs.writeFile(tmpScriptPath, script, 'utf8');\n args.push(tmpScriptPath);\n } else {\n args.push('-e', command);\n }\n log.info(`Running ${OSASCRIPT} with arguments: ${util.quote(args)}`);\n try {\n const {stdout} = await exec(OSASCRIPT, args, {cwd, timeout});\n return stdout;\n } catch (e) {\n throw new Error(e.stderr || e.message);\n }\n } finally {\n if (t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,CAAKC,KAAL,CAAWZ,IAAX,CAAiB,EAAlE;;IACA,IAAI;MACF,MAAM;QAACa;MAAD,IAAW,MAAM,IAAAC,kBAAA,EAAK7B,SAAL,EAAgBe,IAAhB,EAAsB;QAACN,GAAD;QAAMC;MAAN,CAAtB,CAAvB;MACA,OAAOkB,MAAP;IACD,CAHD,CAGE,OAAOE,CAAP,EAAU;MACV,MAAM,IAAIC,KAAJ,CAAUD,CAAC,CAACE,MAAF,IAAYF,CAAC,CAACG,OAAxB,CAAN;IACD;EACF,CAhBD,SAgBU;IACR,IAAIhB,OAAJ,EAAa;MACX,MAAMM,WAAA,CAAGW,MAAH,CAAUjB,OAAV,CAAN;IACD;EACF;AACF,CA7CD;;eAgDef,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","names":["commands","EXTENSION_COMMANDS_MAPPING","setValue","click","scroll","swipe","rightClick","hover","doubleClick","clickAndDrag","clickAndDragAndHold","keys","tap","doubleTap","press","pressAndDrag","pressAndDragAndHold","source","launchApp","activateApp","terminateApp","queryAppState","appleScript","startRecordingScreen","stopRecordingScreen","screenshots","execute","script","args","match","log","info","replace","trim","executeMacosCommand","_","isArray","errors","NotImplementedError","command","opts","has","UnknownCommandError"],"sources":["../../../lib/commands/execute.js"],"sourcesContent":["import _ from 'lodash';\nimport { errors } from 'appium/driver';\nimport log from '../logger';\n\nconst commands = {};\n\nconst EXTENSION_COMMANDS_MAPPING = {\n setValue: 'macosSetValue',\n click: 'macosClick',\n scroll: 'macosScroll',\n swipe: 'macosSwipe',\n rightClick: 'macosRightClick',\n hover: 'macosHover',\n doubleClick: 'macosDoubleClick',\n clickAndDrag: 'macosClickAndDrag',\n clickAndDragAndHold: 'macosClickAndDragAndHold',\n keys: 'macosKeys',\n\n tap: 'macosTap',\n doubleTap: 'macosDoubleTap',\n press: 'macosPress',\n pressAndDrag: 'macosPressAndDrag',\n pressAndDragAndHold: 'macosPressAndDragAndHold',\n\n source: 'macosSource',\n\n launchApp: 'macosLaunchApp',\n activateApp: 'macosActivateApp',\n terminateApp: 'macosTerminateApp',\n queryAppState: 'macosQueryAppState',\n\n appleScript: 'macosExecAppleScript',\n\n startRecordingScreen: 'startRecordingScreen',\n stopRecordingScreen: 'stopRecordingScreen',\n\n screenshots: 'macosScreenshots',\n};\n\ncommands.execute = async function execute (script, args) {\n if (script.match(/^macos:/)) {\n log.info(`Executing extension command '${script}'`);\n script = script.replace(/^macos:/, '').trim();\n return await this.executeMacosCommand(script, _.isArray(args) ? args[0] : args);\n }\n throw new errors.NotImplementedError();\n};\n\ncommands.executeMacosCommand = async function executeMacosCommand (command, opts = {}) {\n if (!_.has(EXTENSION_COMMANDS_MAPPING, command)) {\n throw new errors.UnknownCommandError(`Unknown extension command \"${command}\". ` +\n `Only ${_.keys(EXTENSION_COMMANDS_MAPPING)} commands are supported.`);\n }\n return await this[EXTENSION_COMMANDS_MAPPING[command]](opts);\n};\n\nexport default commands;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;AAEA,MAAMC,0BAA0B,GAAG;EACjCC,QAAQ,EAAE,eADuB;EAEjCC,KAAK,EAAE,YAF0B;EAGjCC,MAAM,EAAE,aAHyB;EAIjCC,KAAK,EAAE,YAJ0B;EAKjCC,UAAU,EAAE,iBALqB;EAMjCC,KAAK,EAAE,YAN0B;EAOjCC,WAAW,EAAE,kBAPoB;EAQjCC,YAAY,EAAE,mBARmB;EASjCC,mBAAmB,EAAE,0BATY;EAUjCC,IAAI,EAAE,WAV2B;EAYjCC,GAAG,EAAE,UAZ4B;EAajCC,SAAS,EAAE,gBAbsB;EAcjCC,KAAK,EAAE,YAd0B;EAejCC,YAAY,EAAE,mBAfmB;EAgBjCC,mBAAmB,EAAE,0BAhBY;EAkBjCC,MAAM,EAAE,aAlByB;EAoBjCC,SAAS,EAAE,gBApBsB;EAqBjCC,WAAW,EAAE,kBArBoB;EAsBjCC,YAAY,EAAE,mBAtBmB;EAuBjCC,aAAa,EAAE,oBAvBkB;EAyBjCC,WAAW,EAAE,sBAzBoB;EA2BjCC,oBAAoB,EAAE,sBA3BW;EA4BjCC,mBAAmB,EAAE,qBA5BY;EA8BjCC,WAAW,EAAE;AA9BoB,CAAnC;;AAiCAzB,QAAQ,CAAC0B,OAAT,GAAmB,eAAeA,OAAf,CAAwBC,MAAxB,EAAgCC,IAAhC,EAAsC;EACvD,IAAID,MAAM,CAACE,KAAP,CAAa,SAAb,CAAJ,EAA6B;IAC3BC,eAAA,CAAIC,IAAJ,CAAU,gCAA+BJ,MAAO,GAAhD;;IACAA,MAAM,GAAGA,MAAM,CAACK,OAAP,CAAe,SAAf,EAA0B,EAA1B,EAA8BC,IAA9B,EAAT;IACA,OAAO,MAAM,KAAKC,mBAAL,CAAyBP,MAAzB,EAAiCQ,eAAA,CAAEC,OAAF,CAAUR,IAAV,IAAkBA,IAAI,CAAC,CAAD,CAAtB,GAA4BA,IAA7D,CAAb;EACD;;EACD,MAAM,IAAIS,cAAA,CAAOC,mBAAX,EAAN;AACD,CAPD;;AASAtC,QAAQ,CAACkC,mBAAT,GAA+B,eAAeA,mBAAf,CAAoCK,OAApC,EAA6CC,IAAI,GAAG,EAApD,EAAwD;EACrF,IAAI,CAACL,eAAA,CAAEM,GAAF,CAAMxC,0BAAN,EAAkCsC,OAAlC,CAAL,EAAiD;IAC/C,MAAM,IAAIF,cAAA,CAAOK,mBAAX,CAAgC,8BAA6BH,OAAQ,KAAtC,GAClC,QAAOJ,eAAA,CAAExB,IAAF,CAAOV,0BAAP,CAAmC,0BADvC,CAAN;EAED;;EACD,OAAO,MAAM,KAAKA,0BAA0B,CAACsC,OAAD,CAA/B,EAA0CC,IAA1C,CAAb;AACD,CAND;;eAQexC,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","names":["commands","findElOrEls","strategy","selector","mult","context","util","unwrapElement","endpoint","wda","proxy","command","using","value"],"sources":["../../../lib/commands/find.js"],"sourcesContent":["import { util } from 'appium/support';\n\n\nconst commands = {};\n\n// This is needed to make lookup by image working\ncommands.findElOrEls = async function findElOrEls (strategy, selector, mult, context) {\n context = util.unwrapElement(context);\n const endpoint = `/element${context ? `/${context}/element` : ''}${mult ? 's' : ''}`;\n\n if (strategy === '-ios predicate string') {\n strategy = 'predicate string';\n } else if (strategy === '-ios class chain') {\n strategy = 'class chain';\n }\n\n return await this.wda.proxy.command(endpoint, 'POST', {\n using: strategy,\n value: selector,\n });\n};\n\n\nexport { commands };\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA;;AAGA,MAAMA,QAAQ,GAAG,EAAjB;;;AAGAA,QAAQ,CAACC,WAAT,GAAuB,eAAeA,WAAf,CAA4BC,QAA5B,EAAsCC,QAAtC,EAAgDC,IAAhD,EAAsDC,OAAtD,EAA+D;EACpFA,OAAO,GAAGC,aAAA,CAAKC,aAAL,CAAmBF,OAAnB,CAAV;EACA,MAAMG,QAAQ,GAAI,WAAUH,OAAO,GAAI,IAAGA,OAAQ,UAAf,GAA2B,EAAG,GAAED,IAAI,GAAG,GAAH,GAAS,EAAG,EAAnF;;EAEA,IAAIF,QAAQ,KAAK,uBAAjB,EAA0C;IACxCA,QAAQ,GAAG,kBAAX;EACD,CAFD,MAEO,IAAIA,QAAQ,KAAK,kBAAjB,EAAqC;IAC1CA,QAAQ,GAAG,aAAX;EACD;;EAED,OAAO,MAAM,KAAKO,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuBH,QAAvB,EAAiC,MAAjC,EAAyC;IACpDI,KAAK,EAAEV,QAD6C;IAEpDW,KAAK,EAAEV;EAF6C,CAAzC,CAAb;AAID,CAdD;;eAkBeH,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestures.js","names":["commands","extractUuid","options","keyNames","name","result","util","unwrapElement","requireUuid","errors","InvalidArgumentError","macosSetValue","opts","uuid","value","text","keyModifierFlags","wda","proxy","command","macosClick","x","y","url","macosScroll","deltaX","deltaY","macosSwipe","direction","velocity","macosRightClick","macosHover","macosDoubleClick","macosClickAndDrag","sourceUuid","destUuid","startX","startY","endX","endY","duration","dest","wrapElement","macosClickAndDragAndHold","holdDuration","macosKeys","keys","macosPressAndHold","macosTap","macosDoubleTap","macosPressAndDrag","macosPressAndDragAndHold"],"sources":["../../../lib/commands/gestures.js"],"sourcesContent":["import { util } from 'appium/support';\nimport { errors } from 'appium/driver';\n\nconst commands = {};\n\nfunction extractUuid (options = {}, keyNames = ['elementId', 'element']) {\n for (const name of keyNames) {\n if (options[name]) {\n const result = util.unwrapElement(options[name]);\n if (result) {\n return result;\n }\n }\n }\n return null;\n}\n\nfunction requireUuid (options = {}, keyNames = ['elementId', 'element']) {\n const result = extractUuid(options, keyNames);\n if (!result) {\n throw new errors.InvalidArgumentError(`${keyNames[0]} field is mandatory`);\n }\n return result;\n}\n\n\n/**\n * @typedef {Object} SetValueOptions\n * @property {!string} elementId uuid of the element to set value for\n * @property {*} value value to set. Could also be an array\n * @property {string} text text to set. If both value and text are set\n * then `value` is preferred\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while the element value is being set. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Set value to the given element\n *\n * @param {SetValueOptions} opts\n */\ncommands.macosSetValue = async function macosSetValue (opts = {}) {\n const uuid = requireUuid(opts);\n const { value, text, keyModifierFlags } = opts;\n return await this.wda.proxy.command(`/element/${uuid}/value`, 'POST', {\n value, text,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} ClickOptions\n * @property {?string} elementId uuid of the element to click. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform click gesture on an element or by relative/absolute coordinates\n *\n * @param {ClickOptions} opts\n */\ncommands.macosClick = async function macosClick (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/element/${uuid}/click` : '/wda/click';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} ScrollOptions\n * @property {?string} elementId uuid of the element to be scrolled. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x scroll X coordinate\n * @property {?number} y scroll Y coordinate\n * @property {!number} deltaX horizontal delta as float number\n * @property {!number} deltaY vertical delta as float number\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while scroll is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform scroll gesture on an element or by relative/absolute coordinates\n *\n * @param {ScrollOptions} opts\n */\ncommands.macosScroll = async function macosScroll (opts = {}) {\n const uuid = extractUuid(opts);\n const {\n x, y,\n deltaX, deltaY,\n keyModifierFlags,\n } = opts;\n const url = uuid ? `/wda/element/${uuid}/scroll` : '/wda/scroll';\n return await this.wda.proxy.command(url, 'POST', {\n deltaX, deltaY,\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} SwipeOptions\n * @property {?string} elementId uuid of the element to be swiped. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x swipe X coordinate\n * @property {?number} y swipe Y coordinate\n * @property {!string} direction either 'up', 'down', 'left' or 'right'\n * @property {?number} velocity The value is measured in pixels per second and same\n * values could behave differently on different devices depending on their display\n * density. Higher values make swipe gesture faster (which usually scrolls larger\n * areas if we apply it to a list) and lower values slow it down.\n * Only values greater than zero have effect.\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while scroll is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform swipe gesture on an element\n *\n * @param {SwipeOptions} opts\n */\ncommands.macosSwipe = async function macosSwipe (opts = {}) {\n const uuid = extractUuid(opts);\n const {\n x, y,\n direction,\n velocity,\n keyModifierFlags,\n } = opts;\n const url = uuid ? `/wda/element/${uuid}/swipe` : `/wda/swipe`;\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n direction,\n velocity,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} RightClickOptions\n * @property {?string} elementId uuid of the element to click. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform right click gesture on an element or by relative/absolute coordinates\n *\n * @param {RightClickOptions} opts\n */\ncommands.macosRightClick = async function macosRightClick (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/rightClick` : '/wda/rightClick';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} HoverOptions\n * @property {?string} elementId uuid of the element to hover. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while hover is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform hover gesture on an element or by relative/absolute coordinates\n *\n * @param {HoverOptions} opts\n */\ncommands.macosHover = async function macosHover (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/hover` : '/wda/hover';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} DoubleClickOptions\n * @property {?string} elementId uuid of the element to double click. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while double click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform double click gesture on an element or by relative/absolute coordinates\n *\n * @param {DoubleClickOptions} opts\n */\ncommands.macosDoubleClick = async function macosDoubleClick (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/doubleClick` : '/wda/doubleClick';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} ClickAndDragOptions\n * @property {?string} sourceElementId uuid of the element to start the drag from. Either this property\n * and `destinationElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?string} destinationElementId uuid of the element to end the drag on. Either this property\n * and `sourceElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?number} startX starting X coordinate\n * @property {?number} startY starting Y coordinate\n * @property {?number} endX ending X coordinate\n * @property {?number} endY ending Y coordinate\n * @property {!number} duration long click duration in float seconds\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while drag is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform long click and drag gesture on an element or by absolute coordinates\n *\n * @param {ClickAndDragOptions} opts\n */\ncommands.macosClickAndDrag = async function macosClickAndDrag (opts = {}) {\n const sourceUuid = extractUuid(opts, ['sourceElementId', 'sourceElement']);\n const destUuid = extractUuid(opts, ['destinationElementId', 'destinationElement']);\n const {\n startX, startY,\n endX, endY,\n duration,\n keyModifierFlags\n } = opts;\n const url = sourceUuid && destUuid\n ? `/wda/element/${sourceUuid}/clickAndDrag`\n : '/wda/clickAndDrag';\n const dest = destUuid && util.wrapElement(destUuid);\n return await this.wda.proxy.command(url, 'POST', {\n startX, startY,\n endX, endY,\n duration,\n dest,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} ClickAndDragAndHoldOptions\n * @property {?string} sourceElementId uuid of the element to start the drag from. Either this property\n * and `destinationElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?string} destinationElementId uuid of the element to end the drag on. Either this property\n * and `sourceElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?number} startX starting X coordinate\n * @property {?number} startY starting Y coordinate\n * @property {?number} endX ending X coordinate\n * @property {?number} endY ending Y coordinate\n * @property {!number} duration long click duration in float seconds\n * @property {?number} velocity dragging velocity in pixels per second.\n * If not provided then the default velocity is used. See\n * https://developer.apple.com/documentation/xctest/xcuigesturevelocity\n * for more details\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while drag is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform long click, drag and hold gesture on an element or by absolute coordinates\n *\n * @param {ClickAndDragAndHoldOptions} opts\n */\ncommands.macosClickAndDragAndHold = async function macosClickAndDragAndHold (opts = {}) {\n const sourceUuid = extractUuid(opts, ['sourceElementId', 'sourceElement']);\n const destUuid = extractUuid(opts, ['destinationElementId', 'destinationElement']);\n const {\n startX, startY,\n endX, endY,\n duration, holdDuration,\n velocity,\n keyModifierFlags\n } = opts;\n const url = sourceUuid && destUuid\n ? `/wda/element/${sourceUuid}/clickAndDragAndHold`\n : '/wda/clickAndDragAndHold';\n const dest = destUuid && util.wrapElement(destUuid);\n return await this.wda.proxy.command(url, 'POST', {\n startX, startY,\n endX, endY,\n duration, holdDuration,\n velocity,\n dest,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} KeyOptions\n * @property {!string} key a string, that represents a key to type (see\n * https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc\n * and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)\n * @property {?number} modifierFlags a set of modifier flags\n * (https://developer.apple.com/documentation/xctest/xcuikeymodifierflags?language=objc)\n * to use when typing the key.\n */\n\n/**\n * @typedef {Object} KeysOptions\n * @property {?string} elementId uuid of the element to send keys to.\n * If the element is not provided then the keys will be sent to the current application.\n * @property {!Array<KeyOptions|string>} keys Array of keys to type.\n * Each item could either be a string, that represents a key itself (see\n * https://developer.apple.com/documentation/xctest/xcuielement/1500604-typekey?language=objc\n * and https://developer.apple.com/documentation/xctest/xcuikeyboardkey?language=objc)\n * or a dictionary, if the key should also be entered with modifiers.\n */\n\n/**\n * Send keys to the given element or to the application under test\n *\n * @param {KeysOptions} opts\n */\ncommands.macosKeys = async function macosKeys (opts = {}) {\n const uuid = extractUuid(opts);\n const { keys } = opts;\n const url = uuid ? `/wda/element/${uuid}/keys` : '/wda/keys';\n return await this.wda.proxy.command(url, 'POST', { keys });\n};\n\n/**\n * @typedef {Object} PressOptions\n * @property {?string} elementId uuid of the Touch Bar element to be pressed. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute Touch Bar coordinates.\n * @property {?number} x long click X coordinate\n * @property {?number} y long click Y coordinate\n * @property {!number} duration the number of float seconds to hold the mouse button\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform press gesture on a Touch Bar element or by relative/absolute coordinates\n *\n * @param {PressOptions} opts\n */\ncommands.macosPressAndHold = async function macosPressAndHold (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, duration, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/press` : '/wda/press';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n duration,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} TapOptions\n * @property {?string} elementId uuid of the Touch Bar element to tap. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute Touch Bar coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform tap gesture on a Touch Bar element or by relative/absolute coordinates\n *\n * @param {TapOptions} opts\n */\ncommands.macosTap = async function macosTap (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/tap` : '/wda/tap';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} DoubleTapOptions\n * @property {?string} elementId uuid of the Touch Bar element to tap. Either this property\n * or/and x and y must be set. If both are set then x and y are considered as relative\n * element coordinates. If only x and y are set then these are parsed as\n * absolute Touch Bar coordinates.\n * @property {?number} x click X coordinate\n * @property {?number} y click Y coordinate\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while click is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform tap gesture on a Touch Bar element or by relative/absolute coordinates\n *\n * @param {DoubleTapOptions} opts\n */\ncommands.macosDoubleTap = async function macosDoubleTap (opts = {}) {\n const uuid = extractUuid(opts);\n const { x, y, keyModifierFlags } = opts;\n const url = uuid ? `/wda/element/${uuid}/doubleTap` : '/wda/doubleTap';\n return await this.wda.proxy.command(url, 'POST', {\n x, y,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} PressAndDragOptions\n * @property {?string} sourceElementId uuid of a Touch Bar element to start the drag from. Either this property\n * and `destinationElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?string} destinationElementId uuid of a Touch Bar element to end the drag on. Either this property\n * and `sourceElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?number} startX starting X coordinate\n * @property {?number} startY starting Y coordinate\n * @property {?number} endX ending X coordinate\n * @property {?number} endY ending Y coordinate\n * @property {!number} duration long click duration in float seconds\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while drag is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform long press and drag gesture on a Touch Bar element or by absolute coordinates\n *\n * @param {PressAndDragOptions} opts\n */\ncommands.macosPressAndDrag = async function macosPressAndDrag (opts = {}) {\n const sourceUuid = extractUuid(opts, ['sourceElementId', 'sourceElement']);\n const destUuid = extractUuid(opts, ['destinationElementId', 'destinationElement']);\n const {\n startX, startY,\n endX, endY,\n duration,\n keyModifierFlags\n } = opts;\n const url = sourceUuid && destUuid\n ? `/wda/element/${sourceUuid}/pressAndDrag`\n : '/wda/pressAndDrag';\n const dest = destUuid && util.wrapElement(destUuid);\n return await this.wda.proxy.command(url, 'POST', {\n startX, startY,\n endX, endY,\n duration,\n dest,\n keyModifierFlags,\n });\n};\n\n/**\n * @typedef {Object} PressAndDragAndHoldOptions\n * @property {?string} sourceElementId uuid of a Touch Bar element to start the drag from. Either this property\n * and `destinationElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?string} destinationElementId uuid of a Touch Bar element to end the drag on. Either this property\n * and `sourceElement` must be provided or `startX`, `startY`, `endX`, `endY` coordinates\n * must be set.\n * @property {?number} startX starting X coordinate\n * @property {?number} startY starting Y coordinate\n * @property {?number} endX ending X coordinate\n * @property {?number} endY ending Y coordinate\n * @property {!number} duration long click duration in float seconds\n * @property {?number} velocity dragging velocity in pixels per second.\n * If not provided then the default velocity is used. See\n * https://developer.apple.com/documentation/xctest/xcuigesturevelocity\n * for more details\n * @property {?number} keyModifierFlags if set then the given key modifiers will be\n * applied while drag is performed. See\n * https://developer.apple.com/documentation/xctest/xcuikeymodifierflags\n * for more details\n */\n\n/**\n * Perform press, drag and hold gesture on a Touch Bar element or by absolute Touch Bar coordinates\n *\n * @param {PressAndDragAndHoldOptions} opts\n */\ncommands.macosPressAndDragAndHold = async function macosPressAndDragAndHold (opts = {}) {\n const sourceUuid = extractUuid(opts, ['sourceElementId', 'sourceElement']);\n const destUuid = extractUuid(opts, ['destinationElementId', 'destinationElement']);\n const {\n startX, startY,\n endX, endY,\n duration, holdDuration,\n velocity,\n keyModifierFlags\n } = opts;\n const url = sourceUuid && destUuid\n ? `/wda/element/${sourceUuid}/pressAndDragAndHold`\n : '/wda/pressAndDragAndHold';\n const dest = destUuid && util.wrapElement(destUuid);\n return await this.wda.proxy.command(url, 'POST', {\n startX, startY,\n endX, endY,\n duration, holdDuration,\n velocity,\n dest,\n keyModifierFlags,\n });\n};\n\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;;AAEA,SAASC,WAAT,CAAsBC,OAAO,GAAG,EAAhC,EAAoCC,QAAQ,GAAG,CAAC,WAAD,EAAc,SAAd,CAA/C,EAAyE;EACvE,KAAK,MAAMC,IAAX,IAAmBD,QAAnB,EAA6B;IAC3B,IAAID,OAAO,CAACE,IAAD,CAAX,EAAmB;MACjB,MAAMC,MAAM,GAAGC,aAAA,CAAKC,aAAL,CAAmBL,OAAO,CAACE,IAAD,CAA1B,CAAf;;MACA,IAAIC,MAAJ,EAAY;QACV,OAAOA,MAAP;MACD;IACF;EACF;;EACD,OAAO,IAAP;AACD;;AAED,SAASG,WAAT,CAAsBN,OAAO,GAAG,EAAhC,EAAoCC,QAAQ,GAAG,CAAC,WAAD,EAAc,SAAd,CAA/C,EAAyE;EACvE,MAAME,MAAM,GAAGJ,WAAW,C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+C;IAEzCC,IAFyC;IAG/CC,QAH+C;IAI/CC,IAJ+C;IAK/CzB;EAL+C,CAApC,CAAb;AAOD,CApBD;;AAkDAhB,QAAQ,CAACmD,wBAAT,GAAoC,eAAeA,wBAAf,CAAyCvC,IAAI,GAAG,EAAhD,EAAoD;EACtF,MAAMsB,UAAU,GAAGjC,WAAW,CAACW,IAAD,EAAO,CAAC,iBAAD,EAAoB,eAApB,CAAP,CAA9B;EACA,MAAMuB,QAAQ,GAAGlC,WAAW,CAACW,IAAD,EAAO,CAAC,sBAAD,EAAyB,oBAAzB,CAAP,CAA5B;EACA,MAAM;IACJwB,MADI;IACIC,MADJ;IAEJC,IAFI;IAEEC,IAFF;IAGJC,QAHI;IAGMI,YAHN;IAIJf,QAJI;IAKJb;EALI,IAMFJ,IANJ;EAOA,MAAMW,GAAG,GAAGW,UAAU,IAAIC,QAAd,GACP,gBAAeD,UAAW,sBADnB,GAER,0BAFJ;;EAGA,MAAMO,IAAI,GAAGN,QAAQ,IAAI7B,aAAA,CAAKoC,WAAL,CAAiBP,QAAjB,CAAzB;;EACA,OAAO,MAAM,KAAKlB,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuBI,GAAvB,EAA4B,MAA5B,EAAoC;IAC/Ca,MAD+C;IACvCC,MADuC;IAE/CC,IAF+C;IAEzCC,IAFyC;IAG/CC,QAH+C;IAGrCI,YAHqC;IAI/Cf,QAJ+C;IAK/CY,IAL+C;IAM/CzB;EAN+C,CAApC,CAAb;AAQD,CAtBD;;eAwBehB,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["commands","Object","assign","findCmds","executeCmds","gestureCmds","sourceCmds","appManagementCmds","appleScriptCmds","screenRecordingCmds","screenshotsCmds"],"sources":["../../../lib/commands/index.js"],"sourcesContent":["import findCmds from './find';\nimport executeCmds from './execute';\nimport gestureCmds from './gestures';\nimport sourceCmds from './source';\nimport appManagementCmds from './app-management';\nimport appleScriptCmds from './applescript';\nimport screenRecordingCmds from './record-screen';\nimport screenshotsCmds from './screenshots';\n\nconst commands = {};\nObject.assign(\n commands,\n findCmds,\n executeCmds,\n gestureCmds,\n sourceCmds,\n appManagementCmds,\n appleScriptCmds,\n screenRecordingCmds,\n screenshotsCmds,\n // add other command types here\n);\n\nexport { commands };\nexport default commands;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;;AACAC,MAAM,CAACC,MAAP,CACEF,QADF,EAEEG,aAFF,EAGEC,gBAHF,EAIEC,iBAJF,EAKEC,eALF,EAMEC,sBANF,EAOEC,oBAPF,EAQEC,qBARF,EASEC,oBATF;eAceV,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-screen.js","names":["commands","RETRY_PAUSE","RETRY_TIMEOUT","DEFAULT_TIME_LIMIT","PROCESS_SHUTDOWN_TIMEOUT","DEFAULT_EXT","FFMPEG_BINARY","DEFAULT_FPS","DEFAULT_PRESET","uploadRecordedMedia","localFile","remotePath","uploadOptions","_","isEmpty","size","fs","stat","log","debug","util","toReadableSizeString","toInMemoryBase64","toString","user","pass","method","headers","fileFieldName","formFields","options","auth","net","uploadFile","requireFfmpegPath","which","e","errorAndThrow","ScreenRecorder","constructor","videoPath","opts","_videoPath","_process","_fps","fps","_deviceId","deviceId","_captureCursor","captureCursor","_captureClicks","captureClicks","_preset","preset","_videoFilter","videoFilter","_timeLimit","timeLimit","getVideoPath","exists","isRunning","_enforceTermination","stop","ign","rimraf","start","ffmpeg","args","fullCmd","SubProcess","slice","quote","on","stdout","stderr","trim","once","code","signal","warn","waitForCondition","Error","waitMs","intervalMs","info","pluralize","force","B","resolve","reject","timer","setTimeout","clearTimeout","proc","stdin","write","end","startRecordingScreen","forceRestart","isNil","_screenRecorder","tempDir","path","prefix","uuidV4","substring","suffix","parseInt","stopRecordingScreen"],"sources":["../../../lib/commands/record-screen.js"],"sourcesContent":["import _ from 'lodash';\nimport { waitForCondition } from 'asyncbox';\nimport { util, fs, net, tempDir } from 'appium/support';\nimport log from '../logger';\nimport { SubProcess } from 'teen_process';\nimport B from 'bluebird';\n\n\nconst commands = {};\n\nconst RETRY_PAUSE = 300;\nconst RETRY_TIMEOUT = 5000;\nconst DEFAULT_TIME_LIMIT = 60 * 10; // 10 minutes\nconst PROCESS_SHUTDOWN_TIMEOUT = 10 * 1000;\nconst DEFAULT_EXT = 'mp4';\nconst FFMPEG_BINARY = 'ffmpeg';\nconst DEFAULT_FPS = 15;\nconst DEFAULT_PRESET = 'veryfast';\n\n\nasync function uploadRecordedMedia (localFile, remotePath = null, uploadOptions = {}) {\n if (_.isEmpty(remotePath)) {\n const {size} = await fs.stat(localFile);\n log.debug(`The size of the resulting screen recording is ${util.toReadableSizeString(size)}`);\n return (await util.toInMemoryBase64(localFile)).toString();\n }\n\n const {user, pass, method, headers, fileFieldName, formFields} = uploadOptions;\n const options = {\n method: method || 'PUT',\n headers,\n fileFieldName,\n formFields,\n };\n if (user && pass) {\n options.auth = {user, pass};\n }\n await net.uploadFile(localFile, remotePath, options);\n return '';\n}\n\nasync function requireFfmpegPath () {\n try {\n return await fs.which(FFMPEG_BINARY);\n } catch (e) {\n log.errorAndThrow(`${FFMPEG_BINARY} has not been found in PATH. ` +\n `Please make sure it is installed`);\n }\n}\n\nclass ScreenRecorder {\n constructor (videoPath, opts = {}) {\n this._videoPath = videoPath;\n this._process = null;\n this._fps = (opts.fps && opts.fps > 0) ? opts.fps : DEFAULT_FPS;\n this._deviceId = opts.deviceId;\n this._captureCursor = opts.captureCursor;\n this._captureClicks = opts.captureClicks;\n this._preset = opts.preset || DEFAULT_PRESET;\n this._videoFilter = opts.videoFilter;\n this._timeLimit = (opts.timeLimit && opts.timeLimit > 0)\n ? opts.timeLimit\n : DEFAULT_TIME_LIMIT;\n }\n\n async getVideoPath () {\n return (await fs.exists(this._videoPath)) ? this._videoPath : '';\n }\n\n isRunning () {\n return !!(this._process?.isRunning);\n }\n\n async _enforceTermination () {\n if (this._process && this.isRunning()) {\n log.debug('Force-stopping the currently running video recording');\n try {\n await this._process.stop('SIGKILL');\n } catch (ign) {}\n }\n this._process = null;\n const videoPath = await this.getVideoPath();\n if (videoPath) {\n await fs.rimraf(videoPath);\n }\n return '';\n }\n\n async start () {\n const ffmpeg = await requireFfmpegPath();\n\n const args = [\n '-loglevel', 'error',\n '-t', `${this._timeLimit}`,\n '-f', 'avfoundation',\n ...(this._captureCursor ? ['-capture_cursor', '1'] : []),\n ...(this._captureClicks ? ['-capture_mouse_clicks', '1'] : []),\n '-framerate', `${this._fps}`,\n '-i', this._deviceId,\n '-vcodec', 'libx264',\n '-preset', this._preset,\n '-tune', 'zerolatency',\n '-pix_fmt', 'yuv420p',\n '-movflags', '+faststart',\n '-fflags', 'nobuffer',\n '-f', DEFAULT_EXT,\n '-r', `${this._fps}`,\n ...(this._videoFilter ? ['-filter:v', this._videoFilter] : []),\n ];\n\n const fullCmd = [\n ffmpeg,\n ...args,\n this._videoPath,\n ];\n this._process = new SubProcess(fullCmd[0], fullCmd.slice(1));\n log.debug(`Starting ${FFMPEG_BINARY}: ${util.quote(fullCmd)}`);\n this._process.on('output', (stdout, stderr) => {\n if (_.trim(stdout || stderr)) {\n log.debug(`[${FFMPEG_BINARY}] ${stdout || stderr}`);\n }\n });\n this._process.once('exit', async (code, signal) => {\n this._process = null;\n if (code === 0) {\n log.debug('Screen recording exited without errors');\n } else {\n await this._enforceTermination();\n log.warn(`Screen recording exited with error code ${code}, signal ${signal}`);\n }\n });\n await this._process.start(0);\n try {\n await waitForCondition(async () => {\n if (await this.getVideoPath()) {\n return true;\n }\n if (!this._process) {\n throw new Error(`${FFMPEG_BINARY} process died unexpectedly`);\n }\n return false;\n }, {\n waitMs: RETRY_TIMEOUT,\n intervalMs: RETRY_PAUSE,\n });\n } catch (e) {\n await this._enforceTermination();\n log.errorAndThrow(`The expected screen record file '${this._videoPath}' does not exist. ` +\n `Check the server log for more details`);\n }\n log.info(`The video recording has started. Will timeout in ${util.pluralize('second', this._timeLimit, true)}`);\n }\n\n async stop (force = false) {\n if (force) {\n return await this._enforceTermination();\n }\n\n if (!this.isRunning()) {\n log.debug('Screen recording is not running. Returning the recent result');\n return await this.getVideoPath();\n }\n\n return new B((resolve, reject) => {\n const timer = setTimeout(async () => {\n await this._enforceTermination();\n reject(new Error(`Screen recording has failed to exit after ${PROCESS_SHUTDOWN_TIMEOUT}ms`));\n }, PROCESS_SHUTDOWN_TIMEOUT);\n\n this._process.once('exit', async (code, signal) => {\n clearTimeout(timer);\n if (code === 0) {\n resolve(await this.getVideoPath());\n } else {\n reject(new Error(`Screen recording exited with error code ${code}, signal ${signal}`));\n }\n });\n\n this._process.proc.stdin.write('q');\n this._process.proc.stdin.end();\n });\n }\n}\n\n\n/**\n * @typedef {Object} StartRecordingOptions\n *\n * @property {?string} videoFilter - The video filter spec to apply for ffmpeg.\n * See https://trac.ffmpeg.org/wiki/FilteringGuide for more details on the possible values.\n * Example: Set it to `scale=ifnot(gte(iw\\,1024)\\,iw\\,1024):-2` in order to limit the video width\n * to 1024px. The height will be adjusted automatically to match the actual ratio.\n * @property {number|string} fps [15] - The count of frames per second in the resulting video.\n * The greater fps it has the bigger file size is.\n * @property {string} preset [veryfast] - One of the supported encoding presets. Possible values are:\n * - ultrafast\n * - superfast\n * - veryfast\n * - faster\n * - fast\n * - medium\n * - slow\n * - slower\n * - veryslow\n * A preset is a collection of options that will provide a certain encoding speed to compression ratio.\n * A slower preset will provide better compression (compression is quality per filesize).\n * This means that, for example, if you target a certain file size or constant bit rate, you will achieve better\n * quality with a slower preset. Read https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.\n * @property {boolean} captureCursor [false] - Whether to capture the mouse cursor while recording\n * the screen\n * @property {boolean} captureClicks [false] - Whether to capture mouse clicks while recording the\n * screen\n * @property {!string|number} deviceId - Screen device index to use for the recording.\n * The list of available devices could be retrieved using\n * `ffmpeg -f avfoundation -list_devices true -i` command.\n * @property {string|number} timeLimit [600] - The maximum recording time, in seconds. The default\n * value is 600 seconds (10 minutes).\n * @property {boolean} forceRestart [true] - Whether to ignore the call if a screen recording is currently running\n * (`false`) or to start a new recording immediately and terminate the existing one if running (`true`).\n */\n\n/**\n * Record the display in background while the automated test is running.\n * This method requires FFMPEG (https://www.ffmpeg.org/download.html) to be installed\n * and present in PATH. Also, the Appium process must be allowed to access screen recording\n * in System Preferences->Security & Privacy->Screen Recording.\n * The resulting video uses H264 codec and is ready to be played by media players built-in into web browsers.\n *\n * @param {?StartRecordingOptions} options - The available options.\n * @throws {Error} If screen recording has failed to start or is not supported on the device under test.\n */\ncommands.startRecordingScreen = async function startRecordingScreen (options = {}) {\n const {\n timeLimit,\n videoFilter,\n fps,\n preset,\n captureCursor,\n captureClicks,\n deviceId,\n forceRestart = true,\n } = options;\n\n if (_.isNil(deviceId)) {\n throw new Error(`'deviceId' option must be provided. Run 'ffmpeg -f avfoundation -list_devices true -i' ` +\n 'to fetch the list of available device ids');\n }\n\n if (this._screenRecorder?.isRunning?.()) {\n log.debug('The screen recording is already running');\n if (!forceRestart) {\n log.debug('Doing nothing');\n return;\n }\n log.debug('Forcing the active screen recording to stop');\n await this._screenRecorder.stop(true);\n }\n this._screenRecorder = null;\n\n const videoPath = await tempDir.path({\n prefix: util.uuidV4().substring(0, 8),\n suffix: `.${DEFAULT_EXT}`,\n });\n this._screenRecorder = new ScreenRecorder(videoPath, {\n fps: parseInt(fps, 10),\n timeLimit: parseInt(timeLimit, 10),\n preset,\n captureCursor,\n captureClicks,\n videoFilter,\n deviceId,\n });\n try {\n await this._screenRecorder.start();\n } catch (e) {\n this._screenRecorder = null;\n throw e;\n }\n};\n\n/**\n * @typedef {Object} StopRecordingOptions\n *\n * @property {?string} remotePath - The path to the remote location, where the resulting video should be uploaded.\n * The following protocols are supported: http/https, ftp.\n * Null or empty string value (the default setting) means the content of resulting\n * file should be encoded as Base64 and passed as the endpoint response value.\n * An exception will be thrown if the generated media file is too big to\n * fit into the available process memory.\n * @property {?string} user - The name of the user for the remote authentication.\n * @property {?string} pass - The password for the remote authentication.\n * @property {?string} method - The http multipart upload method name. The 'PUT' one is used by default.\n * @property {?Object} headers - Additional headers mapping for multipart http(s) uploads\n * @property {?string} fileFieldName [file] - The name of the form field, where the file content BLOB should be stored for\n * http(s) uploads\n * @property {?Object|Array<Pair>} formFields - Additional form fields for multipart http(s) uploads\n */\n\n/**\n * Stop recording the screen.\n * If no screen recording has been started before then the method returns an empty string.\n *\n * @param {?StopRecordingOptions} options - The available options.\n * @returns {string} Base64-encoded content of the recorded media file if 'remotePath'\n * parameter is falsy or an empty string.\n * @throws {Error} If there was an error while getting the name of a media file\n * or the file content cannot be uploaded to the remote location\n * or screen recording is not supported on the device under test.\n */\ncommands.stopRecordingScreen = async function stopRecordingScreen (options = {}) {\n if (!this._screenRecorder) {\n log.debug('No screen recording has been started. Doing nothing');\n return '';\n }\n\n log.debug('Retrieving the resulting video data');\n const videoPath = await this._screenRecorder.stop();\n if (!videoPath) {\n log.debug('No video data is found. Returning an empty string');\n return '';\n }\n return await uploadRecordedMedia(videoPath, options.remotePath, options);\n};\n\nexport default commands;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA,MAAMA,QAAQ,GAAG,EAAjB;AAEA,MAAMC,WAAW,GAAG,GAApB;AACA,MAAMC,aAAa,GAAG,IAAtB;AACA,MAAMC,kBAAkB,GAAG,KAAK,EAAhC;AACA,MAAMC,wBAAwB,GAAG,KAAK,IAAtC;AACA,MAAMC,WAAW,GAAG,KAApB;AACA,MAAMC,aAAa,GAAG,QAAtB;AACA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,cAAc,GAAG,UAAvB;;AAGA,eAAeC,mBAAf,CAAoCC,SAApC,EAA+CC,UAAU,GAAG,IAA5D,EAAkEC,aAAa,GAAG,EAAlF,EAAsF;EACpF,IAAIC,eAAA,CAAEC,OAAF,CAAU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B,eAAA,CAAIC,KAAJ,CAAU,mDAAV;;IACA,OAAO,EAAP;EACD;;EACD,OAAO,MAAMV,mBAAmB,CAAC+B,SAAD,EAAYV,OAAO,CAACnB,UAApB,EAAgCmB,OAAhC,CAAhC;AACD,CAbD;;eAee9B,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.js","names":["commands","macosScreenshots","opts","displayId","wda","proxy","command"],"sources":["../../../lib/commands/screenshots.js"],"sourcesContent":["const commands = {};\n\n/**\n * @typedef {Object} ScreenshotsInfo\n *\n * A dictionary where each key contains a unique display identifier\n * and values are dictionaries with following items:\n * - id: Display identifier\n * - isMain: Whether this display is the main one\n * - payload: The actual PNG screenshot data encoded to base64 string\n */\n\n/**\n * @typedef {Object} ScreenshotsOpts\n * @property {number?} displayId macOS display identifier to take a screenshot for.\n * If not provided then screenshots of all displays are going to be returned.\n * If no matches were found then an error is thrown.\n */\n\n/**\n * Retrieves screenshots of each display available to macOS\n *\n * @param {ScreenshotsOpts} opts\n * @returns {ScreenshotsInfo}\n */\ncommands.macosScreenshots = async function macosScreenshots (opts = {}) {\n const {displayId} = opts;\n return await this.wda.proxy.command('/wda/screenshots', 'POST', {displayId});\n};\n\nexport { commands };\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA,MAAMA,QAAQ,GAAG,EAAjB;;;AAyBAA,QAAQ,CAACC,gBAAT,GAA4B,eAAeA,gBAAf,CAAiCC,IAAI,GAAG,EAAxC,EAA4C;EACtE,MAAM;IAACC;EAAD,IAAcD,IAApB;EACA,OAAO,MAAM,KAAKE,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAuB,kBAAvB,EAA2C,MAA3C,EAAmD;IAACH;EAAD,CAAnD,CAAb;AACD,CAHD;;eAMeH,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","names":["commands","macosSource","opts","format","wda","proxy","command","encodeURIComponent"],"sources":["../../../lib/commands/source.js"],"sourcesContent":["const commands = {};\n\n/**\n * @typedef {Object} SourceOptions\n * @property {?string} format [xml] The format of the application source to retrieve.\n * Only two formats are supported:\n * - xml: Returns the source formatted as XML document (the default setting)\n * - description: Returns the source formatted as debugDescription output.\n * See https://developer.apple.com/documentation/xctest/xcuielement/1500909-debugdescription?language=objc\n * for more details.\n */\n\n/**\n * Retrieves the string representation of the current application\n *\n * @param {?SourceOptions} opts\n * @returns {string} the page source in the requested format\n */\ncommands.macosSource = async function macosSource (opts = {}) {\n const {\n format = 'xml',\n } = opts;\n return await this.wda.proxy.command(`/source?format=${encodeURIComponent(format)}`, 'GET');\n};\n\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA,MAAMA,QAAQ,GAAG,EAAjB;;AAkBAA,QAAQ,CAACC,WAAT,GAAuB,eAAeA,WAAf,CAA4BC,IAAI,GAAG,EAAnC,EAAuC;EAC5D,MAAM;IACJC,MAAM,GAAG;EADL,IAEFD,IAFJ;EAGA,OAAO,MAAM,KAAKE,GAAL,CAASC,KAAT,CAAeC,OAAf,CAAwB,kBAAiBC,kBAAkB,CAACJ,MAAD,CAAS,EAApE,EAAuE,KAAvE,CAAb;AACD,CALD;;eAOeH,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desired-caps.js","names":["desiredCapConstraints","systemPort","isNumber","systemHost","isString","showServerLogs","isBoolean","bootstrapRoot","serverStartupTimeout","bundleId","arguments","isArray","environment","isObject","noReset","skipAppKill","prerun","postrun","webDriverAgentMacUrl"],"sources":["../../lib/desired-caps.js"],"sourcesContent":["const desiredCapConstraints = {\n systemPort: {\n isNumber: true\n },\n systemHost: {\n isString: true\n },\n showServerLogs: {\n isBoolean: true\n },\n bootstrapRoot: {\n isString: true\n },\n serverStartupTimeout: {\n isNumber: true\n },\n bundleId: {\n isString: true\n },\n arguments: {\n isArray: true\n },\n environment: {\n isObject: true\n },\n noReset: {\n isBoolean: true\n },\n skipAppKill: {\n isBoolean: true\n },\n prerun: {\n isObject: true\n },\n postrun: {\n isObject: true\n },\n webDriverAgentMacUrl: {\n isString: true\n }\n};\n\nexport { desiredCapConstraints };\n"],"mappings":";;;;;;;;;AAAA,MAAMA,qBAAqB,GAAG;EAC5BC,UAAU,EAAE;IACVC,QAAQ,EAAE;EADA,CADgB;EAI5BC,UAAU,EAAE;IACVC,QAAQ,EAAE;EADA,CAJgB;EAO5BC,cAAc,EAAE;IACdC,SAAS,EAAE;EADG,CAPY;EAU5BC,aAAa,EAAE;IACbH,QAAQ,EAAE;EADG,CAVa;EAa5BI,oBAAoB,EAAE;IACpBN,QAAQ,EAAE;EADU,CAbM;EAgB5BO,QAAQ,EAAE;IACRL,QAAQ,EAAE;EADF,CAhBkB;EAmB5BM,SAAS,EAAE;IACTC,OAAO,EAAE;EADA,CAnBiB;EAsB5BC,WAAW,EAAE;IACXC,QAAQ,EAAE;EADC,CAtBe;EAyB5BC,OAAO,EAAE;IACPR,SAAS,EAAE;EADJ,CAzBmB;EA4B5BS,WAAW,EAAE;IACXT,SAAS,EAAE;EADA,CA5Be;EA+B5BU,MAAM,EAAE;IACNH,QAAQ,EAAE;EADJ,CA/BoB;EAkC5BI,OAAO,EAAE;IACPJ,QAAQ,EAAE;EADH,CAlCmB;EAqC5BK,oBAAoB,EAAE;IACpBd,QAAQ,EAAE;EADU;AArCM,CAA9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","names":["NO_PROXY","RegExp","Mac2Driver","BaseDriver","constructor","opts","desiredCapConstraints","locatorStrategies","resetState","settings","DeviceSettings","onSettingsUpdate","bind","cmd","fn","_","toPairs","commands","prototype","key","value","wda","proxy","command","proxyReqRes","isProxyActive","_screenRecorder","proxyActive","getProxyAvoidList","canProxy","proxyCommand","url","method","body","createSession","args","sessionId","caps","WDA_MAC_SERVER","prerun","isString","script","Error","log","info","output","macosExecAppleScript","trim","startSession","e","deleteSession","stop","stopSession","postrun","error","message"],"sources":["../../lib/driver.js"],"sourcesContent":["import _ from 'lodash';\nimport { BaseDriver, DeviceSettings } from 'appium/driver';\nimport WDA_MAC_SERVER from './wda-mac';\nimport { desiredCapConstraints } from './desired-caps';\nimport commands from './commands/index';\nimport log from './logger';\n\nconst NO_PROXY = [\n ['GET', new RegExp('^/session/[^/]+/appium')],\n ['POST', new RegExp('^/session/[^/]+/appium')],\n ['POST', new RegExp('^/session/[^/]+/element/[^/]+/elements?$')],\n ['POST', new RegExp('^/session/[^/]+/elements?$')],\n ['POST', new RegExp('^/session/[^/]+/execute')],\n ['POST', new RegExp('^/session/[^/]+/execute/sync')],\n ['GET', new RegExp('^/session/[^/]+/timeouts$')],\n ['POST', new RegExp('^/session/[^/]+/timeouts$')],\n];\n\nclass Mac2Driver extends BaseDriver {\n constructor (opts = {}) {\n super(opts);\n this.desiredCapConstraints = desiredCapConstraints;\n this.locatorStrategies = [\n 'id',\n 'name',\n 'accessibility id',\n\n 'xpath',\n\n 'class name',\n\n '-ios predicate string',\n 'predicate string',\n\n '-ios class chain',\n 'class chain',\n ];\n this.resetState();\n this.settings = new DeviceSettings({}, this.onSettingsUpdate.bind(this));\n\n for (const [cmd, fn] of _.toPairs(commands)) {\n Mac2Driver.prototype[cmd] = fn;\n }\n }\n\n async onSettingsUpdate (key, value) {\n return await this.wda.proxy.command('/appium/settings', 'POST', {\n settings: {[key]: value}\n });\n }\n\n resetState () {\n this.wda = null;\n this.proxyReqRes = null;\n this.isProxyActive = false;\n this._screenRecorder = null;\n }\n\n proxyActive () {\n return this.isProxyActive;\n }\n\n getProxyAvoidList () {\n return NO_PROXY;\n }\n\n canProxy () {\n return true;\n }\n\n async proxyCommand (url, method, body = null) {\n return await this.wda.proxy.command(url, method, body);\n }\n\n async createSession (...args) {\n const [sessionId, caps] = await super.createSession(...args);\n this.wda = WDA_MAC_SERVER;\n try {\n if (caps.prerun) {\n if (!_.isString(caps.prerun.command) && !_.isString(caps.prerun.script)) {\n throw new Error(`'prerun' capability value must either contain ` +\n `'script' or 'command' entry of string type`);\n }\n log.info('Executing prerun AppleScript');\n const output = await this.macosExecAppleScript(caps.prerun);\n if (_.trim(output)) {\n log.info(`Prerun script output: ${output}`);\n }\n }\n await this.wda.startSession(caps);\n } catch (e) {\n await this.deleteSession();\n throw e;\n }\n this.proxyReqRes = this.wda.proxy.proxyReqRes.bind(this.wda.proxy);\n this.isProxyActive = true;\n return [sessionId, caps];\n }\n\n async deleteSession () {\n await this._screenRecorder?.stop(true);\n await this.wda?.stopSession();\n\n if (this.opts.postrun) {\n if (!_.isString(this.opts.postrun.command) && !_.isString(this.opts.postrun.script)) {\n log.error(`'postrun' capability value must either contain ` +\n `'script' or 'command' entry of string type`);\n } else {\n log.info('Executing postrun AppleScript');\n try {\n const output = await this.macosExecAppleScript(this.opts.postrun);\n if (_.trim(output)) {\n log.info(`Postrun script output: ${output}`);\n }\n } catch (e) {\n log.error(e.message);\n }\n }\n }\n\n this.resetState();\n\n await super.deleteSession();\n }\n}\n\nexport default Mac2Driver;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,CACf,CAAC,KAAD,EAAQ,IAAIC,MAAJ,CAAW,wBAAX,CAAR,CADe,EAEf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,wBAAX,CAAT,CAFe,EAGf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,0CAAX,CAAT,CAHe,EAIf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,4BAAX,CAAT,CAJe,EAKf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,yBAAX,CAAT,CALe,EAMf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,8BAAX,CAAT,CANe,EAOf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,2BAAX,CAAR,CAPe,EAQf,CAAC,MAAD,EAAS,IAAIA,MAAJ,CAAW,2BAAX,CAAT,CARe,CAAjB;;AAWA,MAAMC,UAAN,SAAyBC,kBAA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2B,IAA3B,CAAN;IACA,oBAAM,KAAK9B,GAAX,8CAAM,UAAU+B,WAAV,EAAN;;IAEA,IAAI,KAAK/C,IAAL,CAAUgD,OAAd,EAAuB;MACrB,IAAI,CAACtC,eAAA,CAAEyB,QAAF,CAAW,KAAKnC,IAAL,CAAUgD,OAAV,CAAkB9B,OAA7B,CAAD,IAA0C,CAACR,eAAA,CAAEyB,QAAF,CAAW,KAAKnC,IAAL,CAAUgD,OAAV,CAAkBZ,MAA7B,CAA/C,EAAqF;QACnFE,eAAA,CAAIW,KAAJ,CAAW,iDAAD,GACP,4CADH;MAED,CAHD,MAGO;QACLX,eAAA,CAAIC,IAAJ,CAAS,+BAAT;;QACA,IAAI;UACF,MAAMC,MAAM,GAAG,MAAM,KAAKC,oBAAL,CAA0B,KAAKzC,IAAL,CAAUgD,OAApC,CAArB;;UACA,IAAItC,eAAA,CAAEgC,IAAF,CAAOF,MAAP,CAAJ,EAAoB;YAClBF,eAAA,CAAIC,IAAJ,CAAU,0BAAyBC,MAAO,EAA1C;UACD;QACF,CALD,CAKE,OAAOI,CAAP,EAAU;UACVN,eAAA,CAAIW,KAAJ,CAAUL,CAAC,CAACM,OAAZ;QACD;MACF;IACF;;IAED,KAAK/C,UAAL;IAEA,MAAM,MAAM0C,aAAN,EAAN;EACD;;AAzGiC;;eA4GrBhD,U"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","names":["log","logger","getLogger"],"sources":["../../lib/logger.js"],"sourcesContent":["import { logger } from 'appium/support';\n\nconst log = logger.getLogger('Mac2Driver');\n\nexport default log;\n"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAMA,GAAG,GAAGC,eAAA,CAAOC,SAAP,CAAiB,YAAjB,CAAZ;;eAEeF,G"}
|
package/build/lib/utils.js
CHANGED
|
@@ -14,29 +14,18 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
14
14
|
|
|
15
15
|
var _teen_process = require("teen_process");
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _support = require("appium/support");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const MODULE_NAME = 'appium-mac2-driver';
|
|
20
20
|
|
|
21
21
|
const getModuleRoot = _lodash.default.memoize(function getModuleRoot() {
|
|
22
|
-
|
|
22
|
+
const root = _support.node.getModuleRootSync(MODULE_NAME, __filename);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
while (!isAtFsRoot) {
|
|
27
|
-
const manifestPath = _path.default.join(currentDir, 'package.json');
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
if (_fs2.default.existsSync(manifestPath) && JSON.parse(_fs2.default.readFileSync(manifestPath, 'utf8')).name === 'appium-mac2-driver') {
|
|
31
|
-
return currentDir;
|
|
32
|
-
}
|
|
33
|
-
} catch (ign) {}
|
|
34
|
-
|
|
35
|
-
currentDir = _path.default.dirname(currentDir);
|
|
36
|
-
isAtFsRoot = currentDir.length <= _path.default.dirname(currentDir).length;
|
|
24
|
+
if (!root) {
|
|
25
|
+
throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
|
|
37
26
|
}
|
|
38
27
|
|
|
39
|
-
|
|
28
|
+
return root;
|
|
40
29
|
});
|
|
41
30
|
|
|
42
31
|
exports.getModuleRoot = getModuleRoot;
|
|
@@ -50,4 +39,4 @@ async function listChildrenProcessIds(parentPid) {
|
|
|
50
39
|
return [pid, _lodash.default.last(rest)];
|
|
51
40
|
}).filter(([, ppid]) => ppid === `${parentPid}`).map(([pid]) => pid);
|
|
52
41
|
}
|
|
53
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJNT0RVTEVfTkFNRSIsImdldE1vZHVsZVJvb3QiLCJfIiwibWVtb2l6ZSIsInJvb3QiLCJub2RlIiwiZ2V0TW9kdWxlUm9vdFN5bmMiLCJfX2Zpb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Q0FPQSxDQUFDLENBQUNFLEdBQUQsQ0FBRCxLQUFXQSxHQVBYLENBQVA7QUFRRCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["MODULE_NAME","getModuleRoot","_","memoize","root","node","getModuleRootSync","__filename","Error","listChildrenProcessIds","parentPid","stdout","exec","split","filter","trim","map","line","pid","rest","last","ppid"],"sources":["../../lib/utils.js"],"sourcesContent":["import _ from 'lodash';\nimport { exec } from 'teen_process';\nimport { node } from 'appium/support';\n\nconst MODULE_NAME = 'appium-mac2-driver';\n\n/**\n * Calculates the path to the current module's root folder\n *\n * @returns {string} The full path to module root\n * @throws {Error} If the current module root folder cannot be determined\n */\nconst getModuleRoot = _.memoize(function getModuleRoot () {\n const root = node.getModuleRootSync(MODULE_NAME, __filename);\n if (!root) {\n throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);\n }\n return root;\n});\n\n/**\n * Retrieves process ids of all the children processes created by the given\n * parent process identifier\n *\n * @param {number|string} parentPid parent process ID\n * @returns {Array<string>} the list of matched children process ids\n * or an empty list if none matched\n */\nasync function listChildrenProcessIds (parentPid) {\n const { stdout } = await exec('ps', ['axu', '-o', 'ppid']);\n // USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND PPID\n return stdout.split('\\n')\n .filter(_.trim)\n .map((line) => {\n const [, pid, ...rest] = line.split(/\\s+/).filter(_.trim);\n return [pid, _.last(rest)];\n })\n .filter(([, ppid]) => ppid === `${parentPid}`)\n .map(([pid]) => pid);\n}\n\nexport { listChildrenProcessIds, getModuleRoot };\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,MAAMA,WAAW,GAAG,oBAApB;;AAQA,MAAMC,aAAa,GAAGC,eAAA,CAAEC,OAAF,CAAU,SAASF,aAAT,GAA0B;EACxD,MAAMG,IAAI,GAAGC,aAAA,CAAKC,iBAAL,CAAuBN,WAAvB,EAAoCO,UAApC,CAAb;;EACA,IAAI,CAACH,IAAL,EAAW;IACT,MAAM,IAAII,KAAJ,CAAW,sCAAqCR,WAAY,iBAA5D,CAAN;EACD;;EACD,OAAOI,IAAP;AACD,CANqB,CAAtB;;;;AAgBA,eAAeK,sBAAf,CAAuCC,SAAvC,EAAkD;EAChD,MAAM;IAAEC;EAAF,IAAa,MAAM,IAAAC,kBAAA,EAAK,IAAL,EAAW,CAAC,KAAD,EAAQ,IAAR,EAAc,MAAd,CAAX,CAAzB;EAEA,OAAOD,MAAM,CAACE,KAAP,CAAa,IAAb,EACJC,MADI,CACGZ,eAAA,CAAEa,IADL,EAEJC,GAFI,CAECC,IAAD,IAAU;IACb,MAAM,GAAGC,GAAH,EAAQ,GAAGC,IAAX,IAAmBF,IAAI,CAACJ,KAAL,CAAW,KAAX,EAAkBC,MAAlB,CAAyBZ,eAAA,CAAEa,IAA3B,CAAzB;IACA,OAAO,CAACG,GAAD,EAAMhB,eAAA,CAAEkB,IAAF,CAAOD,IAAP,CAAN,CAAP;EACD,CALI,EAMJL,MANI,CAMG,CAAC,GAAGO,IAAH,CAAD,KAAcA,IAAI,KAAM,GAAEX,SAAU,EANvC,EAOJM,GAPI,CAOA,CAAC,CAACE,GAAD,CAAD,KAAWA,GAPX,CAAP;AAQD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wda-mac.js","names":["log","logger","getLogger","DEFAULT_WDA_ROOT","path","resolve","getModuleRoot","WDA_PROJECT_NAME","WDA_PROJECT","wdaRoot","RUNNER_SCHEME","DISABLE_STORE_ARG","XCODEBUILD","STARTUP_TIMEOUT_MS","DEFAULT_SYSTEM_PORT","DEFAULT_SYSTEM_HOST","DEFAULT_SHOW_SERVER_LOGS","RUNNING_PROCESS_IDS","RECENT_UPGRADE_TIMESTAMP_PATH","join","getUpgradeTimestamp","packageManifest","fs","exists","mtime","stat","getTime","cleanupObsoleteProcesses","_","isEmpty","debug","length","util","pluralize","exec","ign","pullAll","process","once","execSync","WDAMacProxy","JWProxy","proxyCommand","url","method","body","didProcessExit","errors","InvalidContextError","WDAMacProcess","constructor","showServerLogs","port","host","bootstrapRoot","proc","isRunning","pid","listChildrenPids","listChildrenProcessIds","isFreshUpgrade","homeFolder","env","HOME","info","currentUpgradeTimestamp","isInteger","timestampPath","access","W_OK","recentUpgradeTimestamp","parseInt","readFile","warn","mkdirp","dirname","writeFile","e","message","hasSameOpts","systemPort","systemHost","isBoolean","isNil","init","opts","Error","kill","xcodebuild","which","args","cwd","stderr","isPortBusy","checkPortStatus","timer","timing","Timer","start","axios","delete","timeout","B","delay","waitForCondition","waitMs","intervalMs","Math","round","getDuration","asMilliSeconds","Object","assign","USE_PORT","USE_HOST","SubProcess","on","stdout","line","trim","code","signal","quote","stop","childrenPids","WDAMacServer","serverStartupTimeoutMs","proxy","isProxyingToRemoteServer","isProxyReady","throwOnExit","command","err","parseProxyProperties","caps","scheme","webDriverAgentMacUrl","server","parsedUrl","URL","protocol","hostname","pathname","isString","split","startSession","serverStartupTimeout","wasProcessInitNecessary","base","keepAlive","test","msg","push","pull","toFixed","capabilities","firstMatch","alwaysMatch","stopSession","sessionId","WDA_MAC_SERVER"],"sources":["../../lib/wda-mac.js"],"sourcesContent":["import _ from 'lodash';\nimport path from 'path';\nimport url from 'url';\nimport axios from 'axios';\nimport B from 'bluebird';\nimport { JWProxy, errors } from 'appium/driver';\nimport { fs, logger, util, timing, mkdirp } from 'appium/support';\nimport { SubProcess, exec } from 'teen_process';\nimport { waitForCondition } from 'asyncbox';\nimport { checkPortStatus } from 'portscanner';\nimport { execSync } from 'child_process';\nimport { listChildrenProcessIds, getModuleRoot } from './utils';\n\nconst log = logger.getLogger('WebDriverAgentMac');\n\nconst DEFAULT_WDA_ROOT = path.resolve(getModuleRoot(), 'WebDriverAgentMac');\nconst WDA_PROJECT_NAME = 'WebDriverAgentMac.xcodeproj';\nconst WDA_PROJECT = (wdaRoot = DEFAULT_WDA_ROOT) => path.resolve(wdaRoot, WDA_PROJECT_NAME);\nconst RUNNER_SCHEME = 'WebDriverAgentRunner';\nconst DISABLE_STORE_ARG = 'COMPILER_INDEX_STORE_ENABLE=NO';\nconst XCODEBUILD = 'xcodebuild';\nconst STARTUP_TIMEOUT_MS = 120000;\nconst DEFAULT_SYSTEM_PORT = 10100;\nconst DEFAULT_SYSTEM_HOST = '127.0.0.1';\nconst DEFAULT_SHOW_SERVER_LOGS = false;\nconst RUNNING_PROCESS_IDS = [];\nconst RECENT_UPGRADE_TIMESTAMP_PATH = path.join('.appium', 'webdriveragent_mac', 'upgrade.time');\n\n\nasync function getUpgradeTimestamp () {\n const packageManifest = path.resolve(getModuleRoot(), 'package.json');\n if (!await fs.exists(packageManifest)) {\n return null;\n }\n const {mtime} = await fs.stat(packageManifest);\n return mtime.getTime();\n}\n\nasync function cleanupObsoleteProcesses () {\n if (!_.isEmpty(RUNNING_PROCESS_IDS)) {\n log.debug(`Cleaning up ${RUNNING_PROCESS_IDS.length} obsolete ` +\n util.pluralize('process', RUNNING_PROCESS_IDS.length, false));\n try {\n await exec('kill', ['-9', ...RUNNING_PROCESS_IDS]);\n } catch (ign) {}\n _.pullAll(RUNNING_PROCESS_IDS, RUNNING_PROCESS_IDS);\n }\n}\n\nprocess.once('exit', () => {\n if (!_.isEmpty(RUNNING_PROCESS_IDS)) {\n try {\n execSync(`kill -9 ${RUNNING_PROCESS_IDS.join(' ')}`);\n } catch (ign) {}\n _.pullAll(RUNNING_PROCESS_IDS, RUNNING_PROCESS_IDS);\n }\n});\n\n\nclass WDAMacProxy extends JWProxy {\n async proxyCommand (url, method, body = null) {\n if (this.didProcessExit) {\n throw new errors.InvalidContextError(\n `'${method} ${url}' cannot be proxied to Mac2 Driver server because ` +\n 'its process is not running (probably crashed). Check the Appium log for more details');\n }\n return await super.proxyCommand(url, method, body);\n }\n}\n\nclass WDAMacProcess {\n constructor () {\n this.showServerLogs = DEFAULT_SHOW_SERVER_LOGS;\n this.port = DEFAULT_SYSTEM_PORT;\n this.host = DEFAULT_SYSTEM_HOST;\n this.bootstrapRoot = DEFAULT_WDA_ROOT;\n this.proc = null;\n }\n\n get isRunning () {\n return !!(this.proc?.isRunning);\n }\n\n get pid () {\n return this.isRunning ? this.proc.pid : null;\n }\n\n async listChildrenPids () {\n return this.pid ? (await listChildrenProcessIds(this.pid)) : [];\n }\n\n async isFreshUpgrade () {\n const homeFolder = process.env.HOME;\n if (!homeFolder) {\n log.info('The HOME folder path cannot be determined');\n return false;\n }\n\n const currentUpgradeTimestamp = await getUpgradeTimestamp();\n if (!_.isInteger(currentUpgradeTimestamp)) {\n log.info('It is impossible to determine the timestamp of the package');\n return false;\n }\n\n const timestampPath = path.resolve(homeFolder, RECENT_UPGRADE_TIMESTAMP_PATH);\n if (await fs.exists(timestampPath)) {\n try {\n await fs.access(timestampPath, fs.W_OK);\n } catch (ign) {\n log.info(`WebDriverAgent upgrade timestamp at '${timestampPath}' is not writeable`);\n return false;\n }\n const recentUpgradeTimestamp = parseInt(await fs.readFile(timestampPath, 'utf8'), 10);\n if (_.isInteger(recentUpgradeTimestamp)) {\n if (recentUpgradeTimestamp >= currentUpgradeTimestamp) {\n log.info(`WebDriverAgent sources are up to date ` +\n `(${recentUpgradeTimestamp} >= ${currentUpgradeTimestamp})`);\n return false;\n }\n log.info(`WebDriverAgent sources have been upgraded ` +\n `(${recentUpgradeTimestamp} < ${currentUpgradeTimestamp})`);\n } else {\n log.warn(`The recent upgrade timestamp at '${timestampPath}' is corrupted. Trying to fix it`);\n }\n }\n\n try {\n await mkdirp(path.dirname(timestampPath));\n await fs.writeFile(timestampPath, `${currentUpgradeTimestamp}`, 'utf8');\n log.debug(`Stored the recent WebDriverAgent upgrade timestamp ${currentUpgradeTimestamp} ` +\n `at '${timestampPath}'`);\n } catch (e) {\n log.info(`Unable to create the recent WebDriverAgent upgrade timestamp at '${timestampPath}'. ` +\n `Original error: ${e.message}`);\n return false;\n }\n\n return true;\n }\n\n hasSameOpts ({ showServerLogs, systemPort, systemHost, bootstrapRoot }) {\n if (_.isBoolean(showServerLogs) && this.showServerLogs !== showServerLogs\n || _.isNil(showServerLogs) && this.showServerLogs !== DEFAULT_SHOW_SERVER_LOGS) {\n return false;\n }\n if (systemPort && this.port !== systemPort\n || !systemPort && this.port !== DEFAULT_SYSTEM_PORT) {\n return false;\n }\n if (systemHost && this.host !== systemHost\n || !systemHost && this.host !== DEFAULT_SYSTEM_HOST) {\n return false;\n }\n if (bootstrapRoot && this.bootstrapRoot !== bootstrapRoot\n || !bootstrapRoot && this.bootstrapRoot !== DEFAULT_WDA_ROOT) {\n return false;\n }\n\n return true;\n }\n\n async init (opts = {}) {\n if (this.isRunning && this.hasSameOpts(opts)) {\n return false;\n }\n\n this.showServerLogs = opts.showServerLogs ?? this.showServerLogs;\n this.port = opts.systemPort ?? this.port;\n this.host = opts.systemHost ?? this.host;\n this.bootstrapRoot = opts.bootstrapRoot ?? this.bootstrapRoot;\n\n log.debug(`Using bootstrap root: ${this.bootstrapRoot}`);\n if (!await fs.exists(WDA_PROJECT(this.bootstrapRoot))) {\n throw new Error(`${WDA_PROJECT_NAME} does not exist at '${WDA_PROJECT(this.bootstrapRoot)}'. ` +\n `Was 'bootstrapRoot' set to a proper value?`);\n }\n\n await this.kill();\n await cleanupObsoleteProcesses();\n\n let xcodebuild;\n try {\n xcodebuild = await fs.which(XCODEBUILD);\n } catch (e) {\n throw new Error(`${XCODEBUILD} binary cannot be found in PATH. ` +\n `Please make sure that Xcode is installed on your system`);\n }\n log.debug(`Using ${XCODEBUILD} binary at '${xcodebuild}'`);\n\n if (await this.isFreshUpgrade()) {\n log.info('Performing project cleanup');\n const args = [\n 'clean',\n '-project', WDA_PROJECT(this.bootstrapRoot),\n '-scheme', RUNNER_SCHEME,\n ];\n try {\n await exec(XCODEBUILD, args, {\n cwd: this.bootstrapRoot,\n });\n } catch (e) {\n log.warn(`Cannot perform project cleanup. ` +\n `Original error: ${e.stderr || e.message}`);\n }\n }\n\n log.debug(`Using ${this.host} as server host`);\n log.debug(`Using port ${this.port}`);\n const isPortBusy = async () => (await checkPortStatus(this.port, this.host)) === 'open';\n if (await isPortBusy()) {\n log.warn(`The port #${this.port} at ${this.host} is busy. ` +\n `Assuming it is an obsolete WDA server instance and ` +\n `trying to terminate it in order to start a new one`);\n const timer = new timing.Timer().start();\n try {\n await axios.delete(`http://${this.host}:${this.port}/`, {\n timeout: 5000,\n });\n // Give the server some time to finish and stop listening\n await B.delay(500);\n await waitForCondition(async () => !(await isPortBusy()), {\n waitMs: 3000,\n intervalMs: 100,\n });\n } catch (e) {\n log.warn(`Did not know how to terminate the process at ${this.host}:${this.port}: ${e.message}. ` +\n `Perhaps, it is not a WDA server, which is hogging the port?`);\n throw new Error(`The port #${this.port} at ${this.host} is busy. ` +\n `Consider setting 'systemPort' capability to another free port number and/or ` +\n `make sure previous driver sessions have been closed properly.`);\n }\n log.info(`The previously running WDA server has been successfully terminated after ` +\n `${Math.round(timer.getDuration().asMilliSeconds)}ms`);\n }\n\n const args = [\n 'build-for-testing', 'test-without-building',\n '-project', WDA_PROJECT(this.bootstrapRoot),\n '-scheme', RUNNER_SCHEME,\n DISABLE_STORE_ARG,\n ];\n const env = Object.assign({}, process.env, {\n USE_PORT: `${this.port}`,\n USE_HOST: this.host,\n });\n this.proc = new SubProcess(xcodebuild, args, {\n cwd: this.bootstrapRoot,\n env,\n });\n if (!this.showServerLogs) {\n log.info(`Mac2Driver host process logging is disabled. ` +\n `All the ${XCODEBUILD} output is going to be suppressed. ` +\n `Set the 'showServerLogs' capability to 'true' if this is an undesired behavior`);\n }\n this.proc.on('output', (stdout, stderr) => {\n if (!this.showServerLogs) {\n return;\n }\n\n const line = _.trim(stdout || stderr);\n if (line) {\n log.debug(`[${XCODEBUILD}] ${line}`);\n }\n });\n this.proc.on('exit', (code, signal) => {\n log.info(`Mac2Driver host process has exited with code ${code}, signal ${signal}`);\n });\n log.info(`Starting Mac2Driver host process: ${XCODEBUILD} ${util.quote(args)}`);\n await this.proc.start(0);\n return true;\n }\n\n async stop () {\n if (!this.isRunning) {\n return;\n }\n\n const childrenPids = await this.listChildrenPids();\n if (!_.isEmpty(childrenPids)) {\n try {\n await exec('kill', childrenPids);\n } catch (ign) {}\n }\n await this.proc.stop('SIGTERM', 3000);\n }\n\n async kill () {\n if (!this.isRunning) {\n return;\n }\n\n const childrenPids = await this.listChildrenPids();\n if (!_.isEmpty(childrenPids)) {\n try {\n await exec('kill', ['-9', ...childrenPids]);\n } catch (ign) {}\n }\n try {\n await this.proc.stop('SIGKILL');\n } catch (ign) {}\n }\n}\n\nclass WDAMacServer {\n constructor () {\n this.process = null;\n this.serverStartupTimeoutMs = STARTUP_TIMEOUT_MS;\n this.proxy = null;\n\n // To handle if the WDAMac server is proxying requests to a remote WDAMac app instance\n this.isProxyingToRemoteServer = false;\n }\n\n async isProxyReady (throwOnExit = true) {\n if (!this.proxy) {\n return false;\n }\n\n try {\n await this.proxy.command('/status', 'GET');\n return true;\n } catch (err) {\n if (throwOnExit && this.proxy.didProcessExit) {\n throw new Error(err.message);\n }\n return false;\n }\n }\n\n\n /**\n * @typedef {Object} ProxyProperties\n *\n * @property {string} scheme - The scheme proxy to.\n * @property {string} host - The host name proxy to.\n * @property {number} port - The port number proxy to.\n * @property {string} path - The path proxy to.\n */\n\n /**\n * Returns proxy information where WDAMacServer proxy to.\n *\n * @param {Object} caps - The capabilities in the session.\n * @return {ProxyProperties}\n * @throws Error if 'webDriverAgentMacUrl' had invalid URL\n */\n parseProxyProperties (caps) {\n let scheme = 'http';\n if (!caps.webDriverAgentMacUrl) {\n return {\n scheme,\n server: (this.process?.host ?? caps.systemHost) ?? DEFAULT_SYSTEM_HOST,\n port: (this.process?.port ?? caps.systemPort) ?? DEFAULT_SYSTEM_PORT,\n path: ''\n };\n }\n\n let parsedUrl;\n try {\n parsedUrl = new url.URL(caps.webDriverAgentMacUrl);\n } catch (e) {\n throw new Error(`webDriverAgentMacUrl, '${caps.webDriverAgentMacUrl}', ` +\n `in the capabilities is invalid. ${e.message}`);\n }\n\n const { protocol, hostname, port, pathname } = parsedUrl;\n if (_.isString(protocol)) {\n scheme = protocol.split(':')[0];\n }\n return {\n scheme,\n server: hostname ?? DEFAULT_SYSTEM_HOST,\n port: _.isEmpty(port) ? DEFAULT_SYSTEM_PORT : _.parseInt(port),\n path: pathname === '/' ? '' : pathname\n };\n }\n\n async startSession (caps) {\n this.serverStartupTimeoutMs = caps.serverStartupTimeout ?? this.serverStartupTimeoutMs;\n\n this.isProxyingToRemoteServer = !!caps.webDriverAgentMacUrl;\n\n let wasProcessInitNecessary;\n if (this.isProxyingToRemoteServer) {\n if (this.process) {\n await this.process.kill();\n await cleanupObsoleteProcesses();\n this.process = null;\n }\n\n wasProcessInitNecessary = false;\n } else {\n if (!this.process) {\n this.process = new WDAMacProcess();\n }\n wasProcessInitNecessary = await this.process.init(caps);\n }\n\n if (wasProcessInitNecessary || this.isProxyingToRemoteServer || !this.proxy) {\n const {scheme, server, port, path} = this.parseProxyProperties(caps);\n this.proxy = new WDAMacProxy({\n scheme,\n server,\n port,\n base: path,\n keepAlive: true,\n });\n this.proxy.didProcessExit = false;\n\n if (this.process) {\n this.process.proc.on('exit', () => {\n this.proxy.didProcessExit = true;\n });\n }\n\n const timer = new timing.Timer().start();\n try {\n await waitForCondition(async () => await this.isProxyReady(), {\n waitMs: this.serverStartupTimeoutMs,\n intervalMs: 1000,\n });\n } catch (e) {\n if (this.process?.isRunning) {\n // avoid \"frozen\" processes,\n await this.process.kill();\n }\n if (/Condition unmet/.test(e.message)) {\n const msg = this.isProxyingToRemoteServer\n ? `No response from '${scheme}://${server}:${port}${path}' within ${this.serverStartupTimeoutMs}ms timeout.` +\n `Please make sure the remote server is running and accessible by Appium`\n : `Mac2Driver server is not listening within ${this.serverStartupTimeoutMs}ms timeout. ` +\n `Try to increase the value of 'serverStartupTimeout' capability, check the server logs ` +\n `and make sure the ${XCODEBUILD} host process could be started manually from a terminal`;\n throw new Error(msg);\n }\n throw e;\n }\n\n if (this.process) {\n const pid = this.process.pid;\n const childrenPids = await this.process.listChildrenPids();\n RUNNING_PROCESS_IDS.push(...childrenPids, pid);\n this.process.proc.on('exit', () => void _.pull(RUNNING_PROCESS_IDS, pid));\n log.info(`The host process is ready within ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);\n }\n } else {\n log.info('The host process has already been listening. Proceeding with session creation');\n }\n\n await this.proxy.command('/session', 'POST', {\n capabilities: {\n firstMatch: [{}],\n alwaysMatch: caps,\n }\n });\n }\n\n async stopSession () {\n if (!this.isProxyingToRemoteServer && !(this.process?.isRunning)) {\n log.info(`Mac2Driver session cannot be stopped, because the server is not running`);\n return;\n }\n\n if (this.proxy?.sessionId) {\n try {\n await this.proxy.command(`/session/${this.proxy.sessionId}`, 'DELETE');\n } catch (e) {\n log.info(`Mac2Driver session cannot be deleted. Original error: ${e.message}`);\n }\n }\n }\n}\n\nconst WDA_MAC_SERVER = new WDAMacServer();\n\nexport default WDA_MAC_SERVER;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,GAAG,GAAGC,eAAA,CAAOC,SAAP,CAAiB,mBAAjB,CAAZ;;AAEA,MAAMC,gBAAgB,GAAGC,aAAA,CAAKC,OAAL,CAAa,IAAAC,oBAAA,GAAb,EAA8B,mBAA9B,CAAzB;;AACA,MAAMC,gBAAgB,GAAG,6BAAzB;;AACA,MAAMC,WAAW,GAAG,CAACC,OAAO,GAAGN,gBAAX,KAAgCC,aAAA,CAAKC,OAAL,CAAaI,OAAb,EAAsBF,gBAAtB,CAApD;;AACA,MAAMG,aAAa,GAAG,sBAAtB;AACA,MAAMC,iBAAiB,GAAG,gCAA1B;AACA,MAAMC,UAAU,GAAG,YAAnB;AACA,MAAMC,kBAAkB,GAAG,MAA3B;AACA,MAAMC,mBAAmB,GAAG,KAA5B;AACA,MAAMC,mBAAmB,GAAG,WAA5B;AACA,MAAMC,wBAAwB,GAAG,KAAjC;A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AAakB,IAAb,CAAkB6D,EAAlB,CAAqB,MAArB,EAA6B,MAAM,KAAKxF,eAAA,CAAE6H,IAAF,CAAOxI,mBAAP,EAA4BwC,GAA5B,CAAxC;QACAzD,GAAG,CAACgE,IAAJ,CAAU,oCAAmC+B,KAAK,CAACc,WAAN,GAAoBC,cAApB,CAAmC4C,OAAnC,CAA2C,CAA3C,CAA8C,IAA3F;MACD;IACF,CA/CD,MA+CO;MACL1J,GAAG,CAACgE,IAAJ,CAAS,+EAAT;IACD;;IAED,MAAM,KAAK+D,KAAL,CAAWI,OAAX,CAAmB,UAAnB,EAA+B,MAA/B,EAAuC;MAC3CwB,YAAY,EAAE;QACZC,UAAU,EAAE,CAAC,EAAD,CADA;QAEZC,WAAW,EAAEvB;MAFD;IAD6B,CAAvC,CAAN;EAMD;;EAEgB,MAAXwB,WAAW,GAAI;IAAA;;IACnB,IAAI,CAAC,KAAK9B,wBAAN,IAAkC,oBAAE,KAAK3F,OAAP,2CAAE,eAAcmB,SAAhB,CAAtC,EAAkE;MAChExD,GAAG,CAACgE,IAAJ,CAAU,yEAAV;MACA;IACD;;IAED,mBAAI,KAAK+D,KAAT,wCAAI,YAAYgC,SAAhB,EAA2B;MACzB,IAAI;QACF,MAAM,KAAKhC,KAAL,CAAWI,OAAX,CAAoB,YAAW,KAAKJ,KAAL,CAAWgC,SAAU,EAApD,EAAuD,QAAvD,CAAN;MACD,CAFD,CAEE,OAAOlF,CAAP,EAAU;QACV7E,GAAG,CAACgE,IAAJ,CAAU,yDAAwDa,CAAC,CAACC,OAAQ,EAA5E;MACD;IACF;EACF;;AAvKgB;;AA0KnB,MAAMkF,cAAc,GAAG,IAAInC,YAAJ,EAAvB;eAEemC,c"}
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { exec } from 'teen_process';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { node } from 'appium/support';
|
|
4
|
+
|
|
5
|
+
const MODULE_NAME = 'appium-mac2-driver';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Calculates the path to the current module's root folder
|
|
@@ -10,20 +11,11 @@ import _fs from 'fs';
|
|
|
10
11
|
* @throws {Error} If the current module root folder cannot be determined
|
|
11
12
|
*/
|
|
12
13
|
const getModuleRoot = _.memoize(function getModuleRoot () {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const manifestPath = path.join(currentDir, 'package.json');
|
|
17
|
-
try {
|
|
18
|
-
if (_fs.existsSync(manifestPath) &&
|
|
19
|
-
JSON.parse(_fs.readFileSync(manifestPath, 'utf8')).name === 'appium-mac2-driver') {
|
|
20
|
-
return currentDir;
|
|
21
|
-
}
|
|
22
|
-
} catch (ign) {}
|
|
23
|
-
currentDir = path.dirname(currentDir);
|
|
24
|
-
isAtFsRoot = currentDir.length <= path.dirname(currentDir).length;
|
|
14
|
+
const root = node.getModuleRootSync(MODULE_NAME, __filename);
|
|
15
|
+
if (!root) {
|
|
16
|
+
throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
|
|
25
17
|
}
|
|
26
|
-
|
|
18
|
+
return root;
|
|
27
19
|
});
|
|
28
20
|
|
|
29
21
|
/**
|