appium-espresso-driver 2.10.0 → 2.11.0
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 +55 -16
- package/build/lib/commands/execute.js.map +1 -0
- package/build/lib/commands/general.js.map +1 -0
- package/build/lib/commands/idling-resources.js.map +1 -0
- package/build/lib/commands/index.js.map +1 -0
- package/build/lib/commands/services.js.map +1 -0
- package/build/lib/desired-caps.js.map +1 -0
- package/build/lib/driver.js.map +1 -0
- package/build/lib/espresso-runner.js.map +1 -0
- package/build/lib/logger.js.map +1 -0
- package/build/lib/server-builder.js.map +1 -0
- package/build/lib/utils.js.map +1 -0
- package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ViewFinder.kt +49 -42
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/HamcrestMatcher.kt +50 -42
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MatcherJson.kt +6 -4
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/HamcrestMatcherTest.kt +66 -34
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MatcherJsonTest.kt +4 -4
- package/npm-shrinkwrap.json +356 -827
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,11 @@ The Espresso package consists of two main parts:
|
|
|
13
13
|
- The driver part (written in Node.js) ensures the communication between the Espresso server and Appium. Also includes several handlers that directly use ADB and/or other system tools without a need to talk to the server.
|
|
14
14
|
- The server part (written in Kotlin with some parts of Java), which is running on the device under test and transforms REST API calls into low-level Espresso commands.
|
|
15
15
|
|
|
16
|
+
> **Note**
|
|
17
|
+
>
|
|
18
|
+
> Since version 2.0.0 Espresso driver has dropped the support of Appium 1, and is only compatible to Appium 2. Use the `appium driver install espresso`
|
|
19
|
+
> command to add it to your Appium 2 dist.
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
## Comparison with UiAutomator2
|
|
18
23
|
|
|
@@ -54,7 +59,7 @@ appium:printPageSourceOnFindFailure | Enforces the server to dump the actual XML
|
|
|
54
59
|
|
|
55
60
|
Capability Name | Description
|
|
56
61
|
--- | ---
|
|
57
|
-
appium:systemPort | The number of the port the Espresso server is listening on. By default the first free port from 8300..8399 range is selected. It is recommended to set this value if you are running [parallel tests](
|
|
62
|
+
appium:systemPort | The number of the port the Espresso server is listening on. By default the first free port from 8300..8399 range is selected. It is recommended to set this value if you are running [parallel tests](docs/parallel-tests.md) on the same machine.
|
|
58
63
|
appium:skipServerInstallation | Skip the Espresso Server component installation on the device under test and all the related checks if set to `true`. This could help to speed up the session startup if you know for sure the correct server version is installed on the device. In case the server is not installed or an incorrect version of it is installed then you may get an unexpected error later. `false` by default
|
|
59
64
|
appium:espressoServerLaunchTimeout | The maximum number of milliseconds to wait util Espresso server is listening on the device. `45000` ms by default
|
|
60
65
|
appium:forceEspressoRebuild | Whether to always enforce Espresso server rebuild (`true`). By default Espresso caches the already built server apk and only rebuilds it when it is necessary, because rebuilding process needs extra time. `false` by default
|
|
@@ -66,11 +71,11 @@ appium:showGradleLog | Whether to include Gradle log to the regular server logs
|
|
|
66
71
|
Capability Name | Description
|
|
67
72
|
--- | ---
|
|
68
73
|
appium:app | Full path to the application to be tested (the app must be located on the same machine where the server is running). The `.apk` application extension is supported. Since driver version 2.1.0 `.aab` files are supported as well (they get converted to `.apk` format automatically if [bundletool.jar](https://github.com/google/bundletool/releases) could be found in your PATH). For older driver versions `.aab` files need to be [converted](https://stackoverflow.com/questions/53040047/generate-apk-file-from-aab-file-android-app-bundle) manually to `.apk` format using [bundletool](https://developer.android.com/studio/command-line/bundletool) first. Could also be an URL to a remote location. If neither of the `app` or `appPackage` capabilities are provided then the driver will fail to start a session. Also, if `app` capability is not provided it is expected that the app under test is already installed on the device under test and `noReset` is equal to `true`.
|
|
69
|
-
appium:appPackage | Application package identifier to be started. If not provided then Espresso will try to detect it automatically from the package provided by the `app` capability. Read [How To Troubleshoot Activities Startup](
|
|
70
|
-
appium:appActivity | Main application activity identifier. If not provided then Espresso will try to detect it automatically from the package provided by the `app` capability. Read [How To Troubleshoot Activities Startup](
|
|
71
|
-
appium:appWaitActivity | Identifier of the first activity that the application invokes. If not provided then equals to `appium:appActivity`. Read [How To Troubleshoot Activities Startup](
|
|
72
|
-
appium:appWaitPackage | Identifier of the first package that is invoked first. If not provided then equals to `appium:appPackage`. Read [How To Troubleshoot Activities Startup](
|
|
73
|
-
appium:appWaitDuration | Maximum amount of milliseconds to wait until the application under test is started (e. g. an activity returns the control to the caller). `20000` ms by default. Read [How To Troubleshoot Activities Startup](
|
|
74
|
+
appium:appPackage | Application package identifier to be started. If not provided then Espresso will try to detect it automatically from the package provided by the `app` capability. Read [How To Troubleshoot Activities Startup](docs/activity-startup.md) for more details
|
|
75
|
+
appium:appActivity | Main application activity identifier. If not provided then Espresso will try to detect it automatically from the package provided by the `app` capability. Read [How To Troubleshoot Activities Startup](docs/activity-startup.md) for more details
|
|
76
|
+
appium:appWaitActivity | Identifier of the first activity that the application invokes. If not provided then equals to `appium:appActivity`. Read [How To Troubleshoot Activities Startup](docs/activity-startup.md) for more details
|
|
77
|
+
appium:appWaitPackage | Identifier of the first package that is invoked first. If not provided then equals to `appium:appPackage`. Read [How To Troubleshoot Activities Startup](docs/activity-startup.md) for more details
|
|
78
|
+
appium:appWaitDuration | Maximum amount of milliseconds to wait until the application under test is started (e. g. an activity returns the control to the caller). `20000` ms by default. Read [How To Troubleshoot Activities Startup](docs/activity-startup.md) for more details
|
|
74
79
|
appium:intentOptions | The mapping of custom options for the intent that is going to be passed to the main app activity. Check [Intent Options](#intent-options) for more details.
|
|
75
80
|
appium:activityOptions | The mapping of custom options for the main app activity that is going to be started. Check [Activity Options](#activity-options) for more details.
|
|
76
81
|
appium:androidInstallTimeout | Maximum amount of milliseconds to wait until the application under test is installed. `90000` ms by default
|
|
@@ -153,8 +158,8 @@ appium:chromedriverPort | The port number to use for Chromedriver communication.
|
|
|
153
158
|
appium:chromedriverPorts | Array of possible port numbers to assign for Chromedriver communication. If none of the port in this array is free then an error is thrown.
|
|
154
159
|
appium:chromedriverArgs | Array of chromedriver [command line arguments](http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/). Note, that not all command line arguments that are available for the desktop browser are also available for the mobile one.
|
|
155
160
|
appium:chromedriverExecutable | Full path to the chromedriver executable on the server file system.
|
|
156
|
-
appium:chromedriverExecutableDir | Full path to the folder where chromedriver executables are located. This folder is used then to store the downloaded chromedriver executables if automatic download is enabled. Read [Automatic Chromedriver Discovery article](
|
|
157
|
-
appium:chromedriverChromeMappingFile | Full path to the chromedrivers mapping file. This file is used to statically map webview/browser versions to the chromedriver versions that are capable of automating them. Read [Automatic Chromedriver Discovery article](
|
|
161
|
+
appium:chromedriverExecutableDir | Full path to the folder where chromedriver executables are located. This folder is used then to store the downloaded chromedriver executables if automatic download is enabled. Read [Automatic Chromedriver Discovery article](docs/hybrid-mode.md#automatic-discovery-of-compatible-chromedriver) for more details.
|
|
162
|
+
appium:chromedriverChromeMappingFile | Full path to the chromedrivers mapping file. This file is used to statically map webview/browser versions to the chromedriver versions that are capable of automating them. Read [Automatic Chromedriver Discovery article](docs/hybrid-mode.md#automatic-discovery-of-compatible-chromedriver) for more details.
|
|
158
163
|
appium:chromedriverUseSystemExecutable | Set it to `true` in order to enforce the usage of chromedriver, which gets downloaded by Appium automatically upon installation. This driver might not be compatible with the destination browser or a web view. `false` by default.
|
|
159
164
|
appium:chromedriverDisableBuildCheck | Being set to `true` disables the compatibility validation between the current chromedriver and the destination browser/web view. Use it with care.
|
|
160
165
|
appium:autoWebviewTimeout | Set the maximum number of milliseconds to wait until a web view is available if `autoWebview` capability is set to `true`. `2000` ms by default
|
|
@@ -361,8 +366,8 @@ accessibility id | This strategy is mapped to the native Espresso `withContentDe
|
|
|
361
366
|
class name | This strategy is mapped to the native Espresso `withClassName` [matcher](https://developer.android.com/reference/androidx/test/espresso/matcher/ViewMatchers#withClassName(org.hamcrest.Matcher%3Cjava.lang.String%3E)) (exact match of element's class name). | 'android.view.View'
|
|
362
367
|
text | This strategy is mapped to the native Espresso `withText` [matcher](https://developer.android.com/reference/androidx/test/espresso/matcher/ViewMatchers#withText(org.hamcrest.Matcher%3Cjava.lang.String%3E)) (exact match of element's text). | 'my text'
|
|
363
368
|
`-android viewtag` or `tag name` | This strategy is mapped to the native Espresso `withTagValue` [matcher](https://developer.android.com/reference/androidx/test/espresso/matcher/ViewMatchers#withtagvalue) (exact match of element's tag value). | 'my tag'
|
|
364
|
-
-android datamatcher | This strategy allows to create Espresso [data interaction](https://developer.android.com/reference/android/support/test/espresso/DataInteraction) selectors which can quickly and reliably scroll to the necessary elements. Read [Espresso DataMatcher Selector](
|
|
365
|
-
-android viewmatcher | This strategy allows
|
|
369
|
+
-android datamatcher | This strategy allows to create Espresso [data interaction](https://developer.android.com/reference/android/support/test/espresso/DataInteraction) selectors which can quickly and reliably scroll to the necessary elements. Read [Espresso DataMatcher Selector](docs/espresso-datamatcher-selector.md) to know more on how to construct these locators. Also check the [Unlocking New Testing Capabilities with Espresso Driver by Daniel Graham](https://www.youtube.com/watch?v=gU9EEUV5n9U) presentation video from Appium Conf 2019. | `{"name": "hasEntry", "args": ["title", "WebView3"]}`
|
|
370
|
+
-android viewmatcher | This strategy allows constructing of Espresso [view matchers](https://developer.android.com/reference/androidx/test/espresso/matcher/ViewMatchers) based on the given JSON representation of them. The representation is expected to contain the following fields: `name`: _mandatory_ matcher function name; `args`: _optional_ matcher function arguments, each argument could also be a function; `class`: _optional_ full qualified class name of the corresponding matcher (if not provided then [org.hamcrest.Matchers](https://hamcrest.org/JavaHamcrest/javadoc/2.2/org/hamcrest/Matchers.html) one is used), `scope` (since Espresso driver 2.11.0): _optional_ JSON representation of a [RootMatchers](https://developer.android.com/reference/androidx/test/espresso/matcher/RootMatchers) method. Check [unit tests](https://github.com/appium/appium-espresso-driver/blob/master/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/HamcrestMatcherTest.kt) for more examples. | `{"name": "withText", "args": [{"name": "containsString", "args": "getExternalStoragePublicDirectory", "class": "org.hamcrest.Matchers"}], "class": "androidx.test.espresso.matcher.ViewMatchers"}`
|
|
366
371
|
xpath | For elements lookup Xpath strategy the driver uses the same XML tree that is generated by page source API. Only Xpath 1.0 is supported. | `By.xpath("//android.view.View[@text=\"Regular\" and @checkable=\"true\"]")`
|
|
367
372
|
|
|
368
373
|
|
|
@@ -384,7 +389,7 @@ Beside of standard W3C APIs the driver provides the following custom command ext
|
|
|
384
389
|
|
|
385
390
|
### mobile: shell
|
|
386
391
|
|
|
387
|
-
Executes the given shell command on the device under test via ADB connection. This extension exposes a potential security risk and thus is only enabled when explicitly activated by the `adb_shell` server
|
|
392
|
+
Executes the given shell command on the device under test via ADB connection. This extension exposes a potential security risk and thus is only enabled when explicitly activated by the `adb_shell` server command line feature specifier
|
|
388
393
|
|
|
389
394
|
#### Arguments
|
|
390
395
|
|
|
@@ -402,7 +407,7 @@ Depending on the `includeStderr` value this API could either return a string, wh
|
|
|
402
407
|
### mobile: execEmuConsoleCommand
|
|
403
408
|
|
|
404
409
|
Executes a command through emulator telnet console interface and returns its output.
|
|
405
|
-
The `emulator_console` server
|
|
410
|
+
The `emulator_console` server feature must be enabled in order to use this method.
|
|
406
411
|
|
|
407
412
|
#### Arguments
|
|
408
413
|
|
|
@@ -419,7 +424,27 @@ The actual command output. An error is thrown if command execution fails.
|
|
|
419
424
|
|
|
420
425
|
### mobile: performEditorAction
|
|
421
426
|
|
|
422
|
-
Performs IME action on the
|
|
427
|
+
Performs IME action on the _currently focused_ edit element.
|
|
428
|
+
|
|
429
|
+
Very often Android developers use [onEditorAction](https://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html#onEditorAction(android.widget.TextView,%20int,%20android.view.KeyEvent)) callback with `actionId` argument to implement actions handling, for example, when `Search` or `Done` button is pressed on the on-screen keyboard. This mobile extension is supposed to emulate the invokation of such callback on the focused element.
|
|
430
|
+
|
|
431
|
+
#### Arguments
|
|
432
|
+
|
|
433
|
+
Name | Type | Required | Description | Example
|
|
434
|
+
--- | --- | --- | --- | ---
|
|
435
|
+
action | string | yes | The name or an integer code of the editor action to be executed. The following action names are supported: `normal, unspecified, none, go, search, send, next, done, previous`. Read [EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo) for more details on this topic. | search
|
|
436
|
+
|
|
437
|
+
#### Examples
|
|
438
|
+
|
|
439
|
+
```java
|
|
440
|
+
// Java
|
|
441
|
+
driver.executeScript("mobile: performEditorAction", ImmutableMap.of("action", "Go"));
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
```python
|
|
445
|
+
# Python
|
|
446
|
+
driver.execute_script('mobile: performEditorAction', {'action': 'previous'})
|
|
447
|
+
```
|
|
423
448
|
|
|
424
449
|
### mobile: changePermissions
|
|
425
450
|
|
|
@@ -450,7 +475,7 @@ Array of strings, where each string is a permission name. the array could be emp
|
|
|
450
475
|
|
|
451
476
|
### mobile: startScreenStreaming
|
|
452
477
|
|
|
453
|
-
Starts device screen broadcast by creating MJPEG server. Multiple calls to this method have no effect unless the previous streaming session is stopped. This method only works if the `adb_screen_streaming`
|
|
478
|
+
Starts device screen broadcast by creating MJPEG server. Multiple calls to this method have no effect unless the previous streaming session is stopped. This method only works if the `adb_screen_streaming` feature is enabled on the server side. It is also required that [GStreamer](https://gstreamer.freedesktop.org/) with `gst-plugins-base`, `gst-plugins-good` and `gst-plugins-bad` packages is installed and available in PATH on the server machine.
|
|
454
479
|
|
|
455
480
|
#### Arguments
|
|
456
481
|
|
|
@@ -1163,10 +1188,24 @@ For example, in the following arguments map
|
|
|
1163
1188
|
the `anotherMethod` will be called on the object returned by `someMethod`, which has no arguments and which was executed on the current activity instance. Also `anotherMethod` accepts to arguments of type `java.lang.CharSequence` and `int`. The result of `anotherMethod` will be serialized and returned to the client.
|
|
1164
1189
|
|
|
1165
1190
|
|
|
1191
|
+
## Parallel Tests
|
|
1192
|
+
|
|
1193
|
+
It is possible to execute tests in parallel using Espresso driver.
|
|
1194
|
+
Appium allows to do this on per-process (multiple server processes running on different ports managing single session)
|
|
1195
|
+
or per-request basis (single server process managing multiple sessions, more preferable, uses less resources and ensures better control over running sessions). Check [Parallel Android Tests](docs/parallel-tests.md) article for
|
|
1196
|
+
more details.
|
|
1197
|
+
|
|
1198
|
+
> **Note**
|
|
1199
|
+
> If you are _not_ going to run your tests in parallel then consider enabling the `--session-override` Appium server argument. It forces the server to close all pending sessions before a new one could be opened,
|
|
1200
|
+
> which allows you to avoid possible issues with such sessions silently running/expiring in the background.
|
|
1201
|
+
|
|
1202
|
+
|
|
1166
1203
|
## Troubleshooting
|
|
1167
1204
|
|
|
1168
|
-
* If
|
|
1169
|
-
*
|
|
1205
|
+
* If you observe Espresso server crash on startup and various exceptions about missing class/method in the logcat output then consider updating [appium:espressoBuildConfig](#espresso-build-config) capability with module versions that match your application under test. This might require some experimentation, as different apps have different module requirements. Check, for example, [issue #812](https://github.com/appium/appium-espresso-driver/issues/812)
|
|
1206
|
+
* If you experince issues with application activities being not found or not starting then consider checking [How To Troubleshoot Activities Startup](docs/activity-startup.md) article.
|
|
1207
|
+
* Espresso requires the debug APK and app-under-test APK (AUT) to have the same signature. It automatically signs the AUT with the `io.appium.espressoserver.test` signature. This may be problematic if you're using an outdated Android SDK tools and/or an outdated Java version.
|
|
1208
|
+
* If there are problems starting a session, set the capability `forceEspressoRebuild` to `true` and retry. This will force rebuilding of Espresso Server. If the following session startup is successfull, set it back to `false`, so the session startup performance is back to normal.
|
|
1170
1209
|
* If you experience session startup failures due to exceptions similar to `Resources$NotFoundException` then try to adjust your ProGuard rules:
|
|
1171
1210
|
```
|
|
1172
1211
|
-dontwarn com.google.android.material.**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","names":["extensions","executeMobile","mobileCommand","opts","mobileCommandsMapping","shell","execEmuConsoleCommand","performEditorAction","changePermissions","getPermissions","startScreenStreaming","stopScreenStreaming","swipe","scrollToPage","navigateTo","clickAction","deviceInfo","isToastVisible","openDrawer","closeDrawer","setDate","setTime","getDeviceTime","backdoor","flashElement","uiautomator","uiautomatorPageSource","webAtoms","getContexts","dismissAutofill","getNotifications","listSms","sensorSet","pushFile","pullFile","pullFolder","deleteFile","isAppInstalled","queryAppState","activateApp","removeApp","terminateApp","installApp","clearApp","startActivity","startService","stopService","broadcast","registerIdlingResources","unregisterIdlingResources","listIdlingResources","unlock","refreshGpsCache","startMediaProjectionRecording","isMediaProjectionRecordingRunning","stopMediaProjectionRecording","_","has","errors","UnknownCommandError","keys"],"sources":["../../../lib/commands/execute.js"],"sourcesContent":["import _ from 'lodash';\nimport { errors } from 'appium/driver';\n\nconst extensions = {};\n\nextensions.executeMobile = async function executeMobile (mobileCommand, opts = {}) {\n const mobileCommandsMapping = {\n shell: 'mobileShell',\n\n execEmuConsoleCommand: 'mobileExecEmuConsoleCommand',\n\n performEditorAction: 'mobilePerformEditorAction',\n\n changePermissions: 'mobileChangePermissions',\n getPermissions: 'mobileGetPermissions',\n\n startScreenStreaming: 'mobileStartScreenStreaming',\n stopScreenStreaming: 'mobileStopScreenStreaming',\n\n swipe: 'mobileSwipe',\n scrollToPage: 'mobileScrollToPage',\n navigateTo: 'mobileNavigateTo',\n clickAction: 'mobileClickAction',\n\n deviceInfo: 'mobileGetDeviceInfo',\n\n isToastVisible: 'mobileIsToastVisible',\n\n openDrawer: 'mobileOpenDrawer',\n closeDrawer: 'mobileCloseDrawer',\n\n setDate: 'mobileSetDate',\n setTime: 'mobileSetTime',\n\n getDeviceTime: 'mobileGetDeviceTime',\n\n backdoor: 'mobileBackdoor',\n\n flashElement: 'mobileFlashElement',\n\n uiautomator: 'mobileUiautomator',\n uiautomatorPageSource: 'mobileUiautomatorPageSource',\n\n webAtoms: 'mobileWebAtoms',\n getContexts: 'mobileGetContexts',\n\n dismissAutofill: 'mobileDismissAutofill',\n\n getNotifications: 'mobileGetNotifications',\n\n listSms: 'mobileListSms',\n\n sensorSet: 'sensorSet',\n\n pushFile: 'mobilePushFile',\n pullFile: 'mobilePullFile',\n pullFolder: 'mobilePullFolder',\n deleteFile: 'mobileDeleteFile',\n\n isAppInstalled: 'mobileIsAppInstalled',\n queryAppState: 'mobileQueryAppState',\n activateApp: 'mobileActivateApp',\n removeApp: 'mobileRemoveApp',\n terminateApp: 'mobileTerminateApp',\n installApp: 'mobileInstallApp',\n clearApp: 'mobileClearApp',\n\n startActivity: 'mobileStartActivity',\n startService: 'mobileStartService',\n stopService: 'mobileStopService',\n broadcast: 'mobileBroadcast',\n\n registerIdlingResources: 'mobileRegisterIdlingResources',\n unregisterIdlingResources: 'mobileUnregisterIdlingResources',\n listIdlingResources: 'mobileListIdlingResources',\n\n unlock: 'mobileUnlock',\n\n refreshGpsCache: 'mobileRefreshGpsCache',\n\n startMediaProjectionRecording: 'mobileStartMediaProjectionRecording',\n isMediaProjectionRecordingRunning: 'mobileIsMediaProjectionRecordingRunning',\n stopMediaProjectionRecording: 'mobileStopMediaProjectionRecording',\n };\n\n if (!_.has(mobileCommandsMapping, mobileCommand)) {\n throw new errors.UnknownCommandError(`Unknown mobile command \"${mobileCommand}\". ` +\n `Only ${_.keys(mobileCommandsMapping)} commands are supported.`);\n }\n return await this[mobileCommandsMapping[mobileCommand]](opts);\n};\n\nexport default extensions;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA,MAAMA,UAAU,GAAG,EAAnB;;AAEAA,UAAU,CAACC,aAAX,GAA2B,eAAeA,aAAf,CAA8BC,aAA9B,EAA6CC,IAAI,GAAG,EAApD,EAAwD;EACjF,MAAMC,qBAAqB,GAAG;IAC5BC,KAAK,EAAE,aADqB;IAG5BC,qBAAqB,EAAE,6BAHK;IAK5BC,mBAAmB,EAAE,2BALO;IAO5BC,iBAAiB,EAAE,yBAPS;IAQ5BC,cAAc,EAAE,sBARY;IAU5BC,oBAAoB,EAAE,4BAVM;IAW5BC,mBAAmB,EAAE,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;IAwE5BC,eAAe,EAAE,uBAxEW;IA0E5BC,6BAA6B,EAAE,qCA1EH;IA2E5BC,iCAAiC,EAAE,yCA3EP;IA4E5BC,4BAA4B,EAAE;EA5EF,CAA9B;;EA+EA,IAAI,CAACC,eAAA,CAAEC,GAAF,CAAMrD,qBAAN,EAA6BF,aAA7B,CAAL,EAAkD;IAChD,MAAM,IAAIwD,cAAA,CAAOC,mBAAX,CAAgC,2BAA0BzD,aAAc,KAAzC,GAClC,QAAOsD,eAAA,CAAEI,IAAF,CAAOxD,qBAAP,CAA8B,0BADlC,CAAN;EAED;;EACD,OAAO,MAAM,KAAKA,qBAAqB,CAACF,aAAD,CAA1B,EAA2CC,IAA3C,CAAb;AACD,CArFD;;eAuFeH,U"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.js","names":["commands","helpers","extensions","assertRequiredOptions","options","requiredOptionNames","_","isArray","presentOptionNames","keys","missingOptionNames","difference","isEmpty","Error","JSON","stringify","launchApp","errors","UnsupportedOperationError","closeApp","reset","getClipboard","adb","getApiLevel","espresso","jwproxy","command","mobilePerformEditorAction","opts","action","mobileSwipe","direction","element","swiper","startCoordinates","endCoordinates","precisionDescriber","util","unwrapElement","mobileGetDeviceInfo","mobileIsToastVisible","text","isRegexp","hasValue","InvalidArgumentError","mobileOpenDrawer","gravity","mobileCloseDrawer","mobileSetDate","year","monthOfYear","dayOfMonth","mobileSetTime","hours","minutes","mobileNavigateTo","menuItemId","menuItemIdAsNumber","parseInt","isNaN","mobileWebAtoms","getDisplayDensity","mobileScrollToPage","scrollToTypes","res","validate","presence","scrollTo","inclusion","within","message","join","scrollToPage","numericality","onlyInteger","greaterThanOrEqualTo","smoothScroll","log","warn","mobileBackdoor","target","methods","elementId","targetElement","mobileUiautomator","strategy","locator","index","mobileUiautomatorPageSource","mobileFlashElement","durationMillis","repeatCount","mobileClickAction","tapper","coordinatesProvider","inputDevice","buttonState","updateSettings","settings","getSettings","suspendChromedriverProxy","chromedriver","proxyReqRes","bind","proxyCommand","jwpProxyActive","mobileStartActivity","appPackage","caps","appActivity","locale","optionalIntentArguments","optionalActivityArguments","startActivity","appWaitPackage","appWaitActivity","qualifyActivityName","debug","waitForActivity","mobileDismissAutofill","Object","assign"],"sources":["../../../lib/commands/general.js"],"sourcesContent":["import _ from 'lodash';\nimport { util } from 'appium/support';\nimport validate from 'validate.js';\nimport { errors } from 'appium/driver';\nimport { qualifyActivityName } from '../utils';\n\nconst commands = {}, helpers = {}, extensions = {};\n\nfunction assertRequiredOptions (options, requiredOptionNames) {\n if (!_.isArray(requiredOptionNames)) {\n requiredOptionNames = [requiredOptionNames];\n }\n const presentOptionNames = _.keys(options);\n const missingOptionNames = _.difference(requiredOptionNames, presentOptionNames);\n if (_.isEmpty(missingOptionNames)) {\n return options;\n }\n throw new Error(`The following options are required: ${JSON.stringify(missingOptionNames)}. ` +\n `You have only provided: ${JSON.stringify(presentOptionNames)}`);\n}\n\n// eslint-disable-next-line require-await\ncommands.launchApp = async function launchApp () {\n throw new errors.UnsupportedOperationError('Please create a new session in order to launch the application under test');\n};\n\n// eslint-disable-next-line require-await\ncommands.closeApp = async function closeApp () {\n throw new errors.UnsupportedOperationError('Please quit the session in order to close the application under test');\n};\n\n// eslint-disable-next-line require-await\ncommands.reset = async function reset () {\n throw new errors.UnsupportedOperationError(\n 'Please quit the session and create a new one ' +\n 'in order to close and launch the application under test');\n};\n\ncommands.getClipboard = async function getClipboard () {\n return (await this.adb.getApiLevel() < 29)\n ? (await this.espresso.jwproxy.command('/appium/device/get_clipboard', 'POST', {}))\n : (await this.adb.getClipboard());\n};\n\ncommands.mobilePerformEditorAction = async function mobilePerformEditorAction (opts = {}) {\n const {action} = assertRequiredOptions(opts, ['action']);\n return await this.espresso.jwproxy.command('/appium/device/perform_editor_action', 'POST', {action});\n};\n\ncommands.mobileSwipe = async function mobileSwipe (opts = {}) {\n const {direction, element, swiper, startCoordinates, endCoordinates, precisionDescriber} = assertRequiredOptions(opts, ['element']);\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/swipe`, 'POST', {\n direction, element, swiper, startCoordinates, endCoordinates, precisionDescriber\n });\n};\n\ncommands.mobileGetDeviceInfo = async function mobileGetDeviceInfo () {\n return await this.espresso.jwproxy.command('/appium/device/info', 'GET');\n};\n\ncommands.mobileIsToastVisible = async function mobileIsToastVisible (opts = {}) {\n const {text, isRegexp} = opts;\n if (!util.hasValue(text)) {\n throw new errors.InvalidArgumentError(`'text' argument is mandatory`);\n }\n return await this.espresso.jwproxy.command('/appium/execute_mobile/is_toast_displayed', 'POST', {\n text,\n isRegexp,\n });\n};\n\ncommands.mobileOpenDrawer = async function mobileOpenDrawer (opts = {}) {\n const {element, gravity} = assertRequiredOptions(opts, ['element']);\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/open_drawer`, 'POST', {\n gravity\n });\n};\n\ncommands.mobileCloseDrawer = async function mobileCloseDrawer (opts = {}) {\n const {element, gravity} = assertRequiredOptions(opts, ['element']);\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/close_drawer`, 'POST', {\n gravity\n });\n};\n\ncommands.mobileSetDate = async function mobileSetDate (opts = {}) {\n const {element, year, monthOfYear, dayOfMonth} = assertRequiredOptions(opts, ['element', 'year', 'monthOfYear', 'dayOfMonth']);\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/set_date`, 'POST', {\n year,\n monthOfYear,\n dayOfMonth,\n });\n};\n\ncommands.mobileSetTime = async function mobileSetTime (opts = {}) {\n const {element, hours, minutes} = assertRequiredOptions(opts, ['element', 'hours', 'minutes']);\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/set_time`, 'POST', {\n hours,\n minutes,\n });\n};\n\ncommands.mobileNavigateTo = async function mobileNavigateTo (opts = {}) {\n let {element, menuItemId} = assertRequiredOptions(opts, ['menuItemId', 'element']);\n\n let menuItemIdAsNumber = parseInt(menuItemId, 10);\n if (_.isNaN(menuItemIdAsNumber) || menuItemIdAsNumber < 0) {\n throw new errors.InvalidArgumentError(`'menuItemId' must be a non-negative number. Found ${menuItemId}`);\n }\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/navigate_to`, 'POST', {\n menuItemId\n });\n};\n\n/**\n * Runs a chain of Espresso web atoms (see https://developer.android.com/training/testing/espresso/web for reference)\n *\n * Takes JSON of the form\n *\n * {\n * \"webviewEl\": \"<ELEMENT_ID>\", // optional webview element to operate on\n * \"forceJavascriptEnabled\": true|false, // if webview disables javascript, webatoms won't work, this forces it\n * \"methodChain\": [\n * {\"name\": \"methodName\", \"atom\": {\"name\": \"atomName\", \"args\": [\"arg1\", \"arg2\", ...]}},\n * ...\n * ]\n * }\n *\n */\ncommands.mobileWebAtoms = async function mobileWebAtoms (opts = {}) {\n opts = assertRequiredOptions(opts, ['methodChain']);\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/web_atoms`, 'POST', opts);\n};\n\ncommands.getDisplayDensity = async function getDisplayDensity () {\n return await this.espresso.jwproxy.command('/appium/device/display_density', 'GET', {});\n};\n\ncommands.mobileScrollToPage = async function mobileScrollToPage (opts = {}) {\n\n // Validate the parameters\n const scrollToTypes = ['first', 'last', 'left', 'right'];\n const res = validate(opts, {\n element: {presence: true},\n scrollTo: {\n inclusion: {\n within: scrollToTypes,\n message: `\"scrollTo\" must be one of \"${scrollToTypes.join(', ')}\" found '%{value}'`,\n }\n },\n scrollToPage: {\n numericality: {\n onlyInteger: true,\n greaterThanOrEqualTo: 0,\n message: `\"scrollToPage\" must be a non-negative integer. Found '%{value}'`\n },\n },\n });\n if (util.hasValue(res)) {\n throw new errors.InvalidArgumentError(`Invalid scrollTo parameters: ${JSON.stringify(res)}`);\n }\n\n const {element, scrollTo, scrollToPage, smoothScroll} = opts;\n\n if (util.hasValue(scrollTo) && util.hasValue(scrollToPage)) {\n this.log.warn(`'scrollTo' and 'scrollToPage' where both provided. Defaulting to 'scrollTo'`);\n }\n\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/scroll_to_page`, 'POST', {\n scrollTo,\n scrollToPage,\n smoothScroll,\n });\n};\n\n\n/**\n * API to invoke methods defined in Android app.\n *\n * Example data\n * {\n * target: 'activity',\n * methods:\n * [\n * {\n * name: \"someMethod\",\n * },\n * {\n * name: \"anotherMethod\",\n * args:\n * [\n * {value: \"Lol\", type: 'java.lang.CharSequence'},\n * {value: 1, type: 'int'}\n * ]\n * }\n * ]\n * }\n *\n * In above example, method \"someMethod\" will be invoked on 'activity'. On the result, \"anotherMethod\" will be invoked\n * \"target\" can be either 'activity', 'application' or 'element'\n * If target is set to 'application', methods will be invoked on application class\n * If target is set to 'activity', methods will be invoked on current activity\n * If target is set to 'element', 'elementId' must be specified\n *\n * - Only 'Public' methods can be invoked. ('open' modifire is necessary in Kotlin)\n * - following primitive types are supported: \"int\", \"boolean\", \"byte\", \"short\", \"long\", \"float\", \"char\"\n * - Non-primitive types with fully qualified name \"java.lang.*\" is also supported:\n * Eg. \"java.lang.CharSequence\", \"java.lang.String\", \"java.lang.Integer\", \"java.lang.Float\",\n * \"java.lang.Double\", \"java.lang.Boolean\", \"java.lang.Long\", \"java.lang.Short\",\n * \"java.lang.Character\" etc...\n *\n *\n * @throws {Error} if target is not 'activity' or 'application'\n * @throws {Error} if a method is not found with given argument types\n *\n * @return {*} the result of the last method in the invocation chain. If method return type is void, then \"<VOID>\" will be returned\n *\n */\ncommands.mobileBackdoor = async function mobileBackdoor (opts = {}) {\n assertRequiredOptions(opts, ['target', 'methods']);\n const {target, methods} = opts;\n if (target === 'element') {\n assertRequiredOptions(opts, ['elementId']);\n }\n const {elementId: targetElement} = opts;\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/backdoor`, 'POST', {target, methods, targetElement});\n};\n\n/**\n * Execute UiAutomator2 commands to drive out of app areas.\n * strategy can be one of: \"clazz\", \"res\", \"text\", \"textContains\", \"textEndsWith\", \"textStartsWith\",\n * \"desc\", \"descContains\", \"descEndsWith\", \"descStartsWith\", \"pkg\"\n *\n * action can be one of: \"click\", \"longClick\", \"getText\", \"getContentDescription\", \"getClassName\",\n * \"getResourceName\", \"getVisibleBounds\", \"getVisibleCenter\", \"getApplicationPackage\",\n * \"getChildCount\", \"clear\", \"isCheckable\", \"isChecked\", \"isClickable\", \"isEnabled\",\n * \"isFocusable\", \"isFocused\", \"isLongClickable\", \"isScrollable\", \"isSelected\"\n */\ncommands.mobileUiautomator = async function mobileUiautomator (opts = {}) {\n const {strategy, locator, action, index} = assertRequiredOptions(opts, ['strategy', 'locator', 'action']);\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/uiautomator`, 'POST', {strategy, locator, index, action});\n};\n\n/**\n * Execute UiAutomator2 command to return the UI dump when AUT is in background.\n * @throws {Error} if uiautomator view dump is unsuccessful\n * @returns {string} uiautomator DOM xml as string\n */\ncommands.mobileUiautomatorPageSource = async function mobileUiautomatorPageSource () {\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/uiautomator_page_source`, 'GET');\n};\n\n/**\n * Flash the element with given id.\n * durationMillis and repeatCount are optional\n *\n */\ncommands.mobileFlashElement = async function mobileFlashElement (opts = {}) {\n const {element} = assertRequiredOptions(opts, ['element']);\n const {durationMillis, repeatCount} = opts;\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/flash`, 'POST', {\n durationMillis,\n repeatCount\n });\n};\n\n/**\n * Perform a 'GeneralClickAction' (https://developer.android.com/reference/androidx/test/espresso/action/GeneralClickAction)\n */\ncommands.mobileClickAction = async function mobileClickAction (opts = {}) {\n const {element, tapper, coordinatesProvider, precisionDescriber,\n inputDevice, buttonState} = assertRequiredOptions(opts, ['element']);\n return await this.espresso.jwproxy.command(`/appium/execute_mobile/${util.unwrapElement(element)}/click_action`, 'POST', {\n tapper, coordinatesProvider, precisionDescriber, inputDevice, buttonState\n });\n};\n\ncommands.updateSettings = async function updateSettings (settings) {\n return await this.espresso.jwproxy.command(`/appium/settings`, 'POST', { settings });\n};\n\ncommands.getSettings = async function getSettings () {\n return await this.espresso.jwproxy.command(`/appium/settings`, 'GET');\n};\n\n// Stop proxying to any Chromedriver and redirect to Espresso\nhelpers.suspendChromedriverProxy = function suspendChromedriverProxy () {\n this.chromedriver = null;\n this.proxyReqRes = this.espresso.proxyReqRes.bind(this.espresso);\n this.proxyCommand = this.espresso.proxyCommand.bind(this.espresso);\n this.jwpProxyActive = true;\n};\n\n/**\n * Starts the given activity with intent options, activity options and locale.\n * Activity could only be executed in scope of the current app package.\n *\n * appActivity is mandatory\n *\n * locale, optionalIntentArguments, optionalActivityArguments are optional\n */\ncommands.mobileStartActivity = async function mobileStartActivity (opts = {}) {\n const appPackage = this.caps.appPackage;\n const {\n appActivity,\n locale,\n optionalIntentArguments,\n optionalActivityArguments\n } = assertRequiredOptions(opts, ['appActivity']);\n return await this.espresso.jwproxy.command(`/appium/device/start_activity`, 'POST', {\n appPackage,\n appActivity,\n locale,\n optionalIntentArguments,\n optionalActivityArguments\n });\n};\n\ncommands.startActivity = async function startActivity (appPackage, appActivity,\n appWaitPackage, appWaitActivity) {\n // intentAction, intentCategory, intentFlags, optionalIntentArguments, dontStopAppOnReset\n // parameters are not supported by Espresso\n appPackage = appPackage || this.caps.appPackage;\n appWaitPackage = appWaitPackage || appPackage;\n appActivity = qualifyActivityName(appActivity, appPackage);\n appWaitActivity = qualifyActivityName(appWaitActivity || appActivity, appWaitPackage);\n this.log.debug(`Starting activity '${appActivity}' for package '${appPackage}'`);\n await this.espresso.jwproxy.command(`/appium/device/start_activity`, 'POST', {\n appPackage,\n appActivity,\n });\n await this.adb.waitForActivity(appWaitPackage, appWaitActivity);\n};\n\ncommands.mobileDismissAutofill = async function mobileDismissAutofill (opts = {}) {\n const {element} = assertRequiredOptions(opts, ['element']);\n await this.espresso.jwproxy.command(\n `/session/:sessionId/appium/execute_mobile/${util.unwrapElement(element)}/dismiss_autofill`, 'POST', {});\n};\n\nObject.assign(extensions, commands, helpers);\nexport { commands, helpers };\nexport default extensions;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;AAAA,MAAqBC,OAAO,GAAG,EAA/B;AAAA,MAAmCC,UAAU,GAAG,EAAhD;;;;AAEA,SAASC,qBAAT,CAAgCC,OAAhC,EAAyCC,mBAAzC,EAA8D;EAC5D,IAAI,CAACC,eAAA,CAAEC,OAAF,CAAUF,mBAAV,CAAL,EAAqC;IACnCA,mBAAmB,GAAG,CAACA,mBAAD,CAAtB;EACD;;EACD,MAAMG,kBAAkB,GAAGF,eAAA,CAAEG,IAAF,CAAOL,OAAP,CAA3B;;EACA,MAAMM,kBAAkB,GAAGJ,eAAA,CAAEK,UAAF,CAAaN,mBAAb,EAAkCG,kBAAlC,CAA3B;;EACA,IAAIF,eAAA,CAAEM,OAAF,CAAUF,kBAAV,CAAJ,EAAmC;IACjC,OAAON,OAAP;EACD;;EACD,MAAM,IAAIS,KAAJ,CAAW,uCAAsCC,IAAI,CAACC,SAAL,CAAeL,kBAAf,CAAmC,IAA1E,GACb,2BAA0BI,IAAI,CAACC,SAAL,CAAeP,kBAAf,CAAmC,EAD1D,CAAN;AAED;;AAGDR,QAAQ,CAACgB,SAAT,GAAqB,eAAeA,SAAf,GAA4B;EAC/C,MAAM,IAAIC,cAAA,CAAOC,yBAAX,CAAqC,2EAArC,CAAN;AACD,CAFD;;AAKAlB,QAAQ,CAACmB,QAAT,GAAoB,eAAeA,QAAf,GAA2B;EAC7C,MAAM,IAAIF,cAAA,CAAOC,yBAAX,CAAqC,sEAArC,CAAN;AACD,CAFD;;AAKAlB,QAAQ,CAACoB,KAAT,GAAiB,eAAeA,KAAf,GAAwB;EACvC,MAAM,IAAIH,cAAA,CAAOC,yBAAX,CACJ,kDACA,yDAFI,CAAN;AAGD,CAJD;;AAMAlB,QAAQ,CAACqB,YAA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G,CAAN;AAED,CAJD;;AAMAwF,MAAM,CAACC,MAAP,CAAcvH,UAAd,EAA0BF,QAA1B,EAAoCC,OAApC;eAEeC,U"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idling-resources.js","names":["commands","mobileRegisterIdlingResources","opts","espresso","jwproxy","command","requireOptions","mobileUnregisterIdlingResources","mobileListIdlingResources"],"sources":["../../../lib/commands/idling-resources.js"],"sourcesContent":["import { requireOptions } from '../utils';\n\nconst commands = {};\n\n/**\n * @typedef {Object} IdlingResourcesOptions\n * @property {!string} classNames - The comma-separated list of idling resources class names.\n * Each name must be a full-qualified java class name, like `io.appium.espressoserver.lib.MyIdlingResource`.\n * Each class in the app source must implement a singleton pattern and have a static `getInstance()`\n * method returning the class instance, which implements `androidx.test.espresso.IdlingResource`\n * interface. Read\n * - https://developer.android.com/training/testing/espresso/idling-resource\n * - https://android.jlelse.eu/integrate-espresso-idling-resources-in-your-app-to-build-flexible-ui-tests-c779e24f5057\n * for more details on how to design and use idling resources concept in Espresso.\n */\n\n/**\n * Registers one or more idling resources\n *\n * @param {IdlingResourcesOptions} opts\n * @throws {Error} If there was a failure while parsing options or registering\n * the actual instances\n */\ncommands.mobileRegisterIdlingResources = async function mobileRegisterIdlingResources (opts = {}) {\n return await this.espresso.jwproxy.command('/appium/execute_mobile/register_idling_resources', 'POST',\n requireOptions(opts, ['classNames']));\n};\n\n/**\n * Unregisters one or more idling resources\n *\n * @param {IdlingResourcesOptions} opts\n * @throws {Error} If there was a failure while parsing options or unregistering\n * the actual instances\n */\ncommands.mobileUnregisterIdlingResources = async function mobileUnregisterIdlingResources (opts = {}) {\n return await this.espresso.jwproxy.command('/appium/execute_mobile/unregister_idling_resources', 'POST',\n requireOptions(opts, ['classNames']));\n};\n\n/**\n * Returns a list of currently registered idling resources\n * or an empty list if no resources have been registered yet.\n *\n * @returns {Array<string>} The list of fully qualified class names\n */\ncommands.mobileListIdlingResources = async function mobileListIdlingResources () {\n return await this.espresso.jwproxy.command('/appium/execute_mobile/list_idling_resources', 'GET');\n};\n\nexport { commands };\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;;;AAqBAA,QAAQ,CAACC,6BAAT,GAAyC,eAAeA,6BAAf,CAA8CC,IAAI,GAAG,EAArD,EAAyD;EAChG,OAAO,MAAM,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,OAAtB,CAA8B,kDAA9B,EAAkF,MAAlF,EACX,IAAAC,qBAAA,EAAeJ,IAAf,EAAqB,CAAC,YAAD,CAArB,CADW,CAAb;AAED,CAHD;;AAYAF,QAAQ,CAACO,+BAAT,GAA2C,eAAeA,+BAAf,CAAgDL,IAAI,GAAG,EAAvD,EAA2D;EACpG,OAAO,MAAM,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,OAAtB,CAA8B,oDAA9B,EAAoF,MAApF,EACX,IAAAC,qBAAA,EAAeJ,IAAf,EAAqB,CAAC,YAAD,CAArB,CADW,CAAb;AAED,CAHD;;AAWAF,QAAQ,CAACQ,yBAAT,GAAqC,eAAeA,yBAAf,GAA4C;EAC/E,OAAO,MAAM,KAAKL,QAAL,CAAcC,OAAd,CAAsBC,OAAtB,CAA8B,8CAA9B,EAA8E,KAA9E,CAAb;AACD,CAFD;;eAKeL,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["commands","Object","assign","generalCmds","executeCmds","servicesCmds","idlingResourcesCmds"],"sources":["../../../lib/commands/index.js"],"sourcesContent":["import executeCmds from './execute';\nimport generalCmds from './general';\nimport servicesCmds from './services';\nimport idlingResourcesCmds from './idling-resources';\n\nconst commands = {};\nObject.assign(\n commands,\n generalCmds,\n executeCmds,\n servicesCmds,\n idlingResourcesCmds,\n // add other command types here\n);\n\nexport default commands;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;AACAC,MAAM,CAACC,MAAP,CACEF,QADF,EAEEG,gBAFF,EAGEC,gBAHF,EAIEC,iBAJF,EAKEC,wBALF;eASeN,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","names":["commands","mobileStartService","opts","espresso","jwproxy","command","requireOptions","mobileStopService"],"sources":["../../../lib/commands/services.js"],"sourcesContent":["import { requireOptions } from '../utils';\n\nconst commands = {};\n\n\n/**\n * @typedef {Object} StartServiceOptions\n * @property {!string} intent - The name of the service intent to start, for example\n * `com.some.package.name/.YourServiceSubClassName`. This option is mandatory.\n * !!! Only services in the app's under test scope could be started.\n * @property {boolean} foreground [false] - Set it to `true` if your service must be\n * started as foreground service.\n */\n\n/**\n * Starts the given service intent.\n *\n * @param {StartServiceOptions} opts\n * @returns {string} The full component name\n * @throws {Error} If there was a failure while starting the service\n * or required options are missing\n */\ncommands.mobileStartService = async function mobileStartService (opts = {}) {\n return await this.espresso.jwproxy.command('/appium/execute_mobile/start_service', 'POST',\n requireOptions(opts, ['intent']));\n};\n\n/**\n * @typedef {Object} StopServiceOptions\n * @property {!string} intent - The name of the service intent to stop, for example\n * `com.some.package.name/.YourServiceSubClassName`. This option is mandatory.\n * !!! Only services in the app's under test scope could be stopped.\n */\n\n/**\n * Stops the given service intent.\n *\n * @param {StopServiceOptions} opts\n * @returns {string} `true` if the service has been successfully stopped\n * @throws {Error} If there was a failure while stopping the service\n * or required options are missing\n */\ncommands.mobileStopService = async function mobileStopService (opts = {}) {\n return await this.espresso.jwproxy.command('/appium/execute_mobile/stop_service', 'POST',\n requireOptions(opts, ['intent']));\n};\n\n\nexport { commands };\nexport default commands;\n"],"mappings":";;;;;;;;;AAAA;;AAEA,MAAMA,QAAQ,GAAG,EAAjB;;;AAoBAA,QAAQ,CAACC,kBAAT,GAA8B,eAAeA,kBAAf,CAAmCC,IAAI,GAAG,EAA1C,EAA8C;EAC1E,OAAO,MAAM,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,OAAtB,CAA8B,sCAA9B,EAAsE,MAAtE,EACX,IAAAC,qBAAA,EAAeJ,IAAf,EAAqB,CAAC,QAAD,CAArB,CADW,CAAb;AAED,CAHD;;AAoBAF,QAAQ,CAACO,iBAAT,GAA6B,eAAeA,iBAAf,CAAkCL,IAAI,GAAG,EAAzC,EAA6C;EACxE,OAAO,MAAM,KAAKC,QAAL,CAAcC,OAAd,CAAsBC,OAAtB,CAA8B,qCAA9B,EAAqE,MAArE,EACX,IAAAC,qBAAA,EAAeJ,IAAf,EAAqB,CAAC,QAAD,CAArB,CADW,CAAb;AAED,CAHD;;eAOeF,Q"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"desired-caps.js","names":["espressoCapConstraints","app","isString","automationName","systemPort","isNumber","browserName","launchTimeout","skipUnlock","isBoolean","forceEspressoRebuild","espressoServerLaunchTimeout","espressoBuildConfig","showGradleLog","skipServerInstallation","intentOptions","isObject","disableSuppressAccessibilityService","activityOptions","appLocale","desiredCapConstraints","Object","assign","commonCapConstraints"],"sources":["../../lib/desired-caps.js"],"sourcesContent":["import { commonCapConstraints } from 'appium-android-driver';\n\nlet espressoCapConstraints = {\n app: {\n isString: true,\n },\n automationName: {\n isString: true,\n },\n systemPort: {\n isNumber: true\n },\n browserName: {\n isString: true\n },\n launchTimeout: {\n isNumber: true\n },\n skipUnlock: {\n isBoolean: true\n },\n forceEspressoRebuild: {\n isBoolean: true\n },\n espressoServerLaunchTimeout: {\n isNumber: true\n },\n espressoBuildConfig: {\n isString: true\n },\n showGradleLog: {\n isBoolean: true\n },\n skipServerInstallation: {\n isBoolean: true\n },\n intentOptions: {\n isObject: true\n },\n disableSuppressAccessibilityService: {\n isBoolean: true\n },\n activityOptions: {\n isObject: true\n },\n appLocale: {\n isObject: true,\n }\n};\n\nlet desiredCapConstraints = {};\nObject.assign(desiredCapConstraints, espressoCapConstraints,\n commonCapConstraints);\n\nexport default desiredCapConstraints;\n"],"mappings":";;;;;;;;;AAAA;;AAEA,IAAIA,sBAAsB,GAAG;EAC3BC,GAAG,EAAE;IACHC,QAAQ,EAAE;EADP,CADsB;EAI3BC,cAAc,EAAE;IACdD,QAAQ,EAAE;EADI,CAJW;EAO3BE,UAAU,EAAE;IACVC,QAAQ,EAAE;EADA,CAPe;EAU3BC,WAAW,EAAE;IACXJ,QAAQ,EAAE;EADC,CAVc;EAa3BK,aAAa,EAAE;IACbF,QAAQ,EAAE;EADG,CAbY;EAgB3BG,UAAU,EAAE;IACVC,SAAS,EAAE;EADD,CAhBe;EAmB3BC,oBAAoB,EAAE;IACpBD,SAAS,EAAE;EADS,CAnBK;EAsB3BE,2BAA2B,EAAE;IAC3BN,QAAQ,EAAE;EADiB,CAtBF;EAyB3BO,mBAAmB,EAAE;IACnBV,QAAQ,EAAE;EADS,CAzBM;EA4B3BW,aAAa,EAAE;IACbJ,SAAS,EAAE;EADE,CA5BY;EA+B3BK,sBAAsB,EAAE;IACtBL,SAAS,EAAE;EADW,CA/BG;EAkC3BM,aAAa,EAAE;IACbC,QAAQ,EAAE;EADG,CAlCY;EAqC3BC,mCAAmC,EAAE;IACnCR,SAAS,EAAE;EADwB,CArCV;EAwC3BS,eAAe,EAAE;IACfF,QAAQ,EAAE;EADK,CAxCU;EA2C3BG,SAAS,EAAE;IACTH,QAAQ,EAAE;EADD;AA3CgB,CAA7B;AAgDA,IAAII,qBAAqB,GAAG,EAA5B;AACAC,MAAM,CAACC,MAAP,CAAcF,qBAAd,EAAqCpB,sBAArC,EACcuB,yCADd;eAGeH,qB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","names":["helpers","androidHelpers","SYSTEM_PORT_RANGE","DEVICE_PORT","NO_PROXY","RegExp","CHROME_NO_PROXY","APK_EXT","AAB_EXT","SUPPORTED_EXTENSIONS","EspressoDriver","BaseDriver","constructor","opts","shouldValidateCaps","shell","locatorStrategies","desiredCapConstraints","espresso","jwpProxyActive","defaultIME","jwpProxyAvoid","apkStrings","settings","DeviceSettings","onSettingsUpdate","bind","chromedriver","sessionChromedrivers","createSession","args","sessionId","caps","serverDetails","platform","webStorageEnabled","takesScreenshot","javascriptEnabled","databaseEnabled","networkConnectionEnabled","locationContextEnabled","warnings","desired","Object","assign","curContext","defaultContextName","defaultOpts","fullReset","autoLaunch","adbPort","DEFAULT_ADB_PORT","androidInstallTimeout","_","defaults","isChromeSession","app","log","warn","errorAndThrow","reboot","setAvdFromCapabilities","addWipeDataToAvdArgs","systemPort","findAPortNotInUse","udid","emPort","getDeviceInfoFromCaps","adb","createADB","configureApp","onPostProcess","onPostConfigureApp","supportedExtensions","appOnDevice","info","appPackage","isAppInstalled","startEspressoSession","e","deleteSession","message","endsWith","isErrorType","errors","SessionNotCreatedError","err","stack","unzipApp","appPath","useSystemUnzipEnv","process","env","APPIUM_PREFER_SYSTEM_UNZIP","useSystemUnzip","isEmpty","includes","toLower","tmpRoot","tempDir","openDir","zip","extractAllTo","globPattern","map","ext","replace","join","sortedBundleItems","fs","glob","cwd","strict","sort","a","b","split","path","sep","length","unzippedAppPath","first","debug","cachedAppInfo","isUrl","presignApp","appLocation","noSign","checkApkCert","sign","hasApkExt","hasAabExt","extractUniversalApk","shouldExtract","pathInCache","isResultAppPathAlreadyCached","isPlainObject","packageHash","hash","exists","fullPath","isApk","shouldResultAppPathBeCached","isUnzippedApk","rimraf","driverData","isEmulator","avd","deviceName","platformVersion","avdDevice","avdArgs","toLowerCase","manifestPayload","getPackageInfo","version","getApiLevel","setHiddenApiPolicy","ignoreHiddenApiPolicyError","appInfo","getLaunchInfo","initDevice","isAnimationOn","setAnimationState","wasAnimationEnabled","curDeviceId","deviceUDID","initEspressoServer","forwardPort","skipUnlock","unlock","initAUT","appWaitPackage","appActivity","qualifyActivityName","appWaitActivity","startSession","waitForActivity","appWaitDuration","autoWebview","initWebview","addDeviceInfoToCaps","viewName","androidCommands","defaultWebviewName","call","timeout","autoWebviewTimeout","retryInterval","setContext","apiVersion","manufacturer","model","realDisplaySize","displayDensity","mobileGetDeviceInfo","deviceApiLevel","parseInt","deviceScreenSize","deviceScreenDensity","deviceModel","deviceManufacturer","EspressoRunner","host","remoteAdbHost","devicePort","apk","tmpDir","forceEspressoRebuild","espressoBuildConfig","showGradleLog","serverLaunchTimeout","espressoServerLaunchTimeout","skipServerInstallation","useKeystore","keystorePath","keystorePassword","keyAlias","keyPassword","disableSuppressAccessibilityService","proxyReqRes","proxyCommand","uninstallOtherPackages","parseArray","SETTINGS_HELPER_PKG_ID","TEST_APK_PKG","fastReset","resetApp","skipUninstall","uninstallApk","installApk","installTestApk","addToDeviceIdleWhitelist","stderr","screenRecordingStopTasks","_screenRecordingProperties","stopRecordingScreen","mobileIsMediaProjectionRecordingRunning","mobileStopMediaProjectionRecording","_screenStreamingProps","mobileStopScreenStreaming","removeAllSessionWebSocketHandlers","server","B","all","task","ign","unicodeKeyboard","resetKeyboard","setIME","dontStopAppOnReset","forceStop","stopLogcat","avdName","killEmulator","setDefaultHiddenApiPolicy","undefined","removePortForward","error","proxyActive","canProxy","getProxyAvoidList","isNil","nativeWebScreenshot","isChromeBrowser","browserName","isPackageOrBundle","cmd","fn","toPairs","prototype","commands"],"sources":["../../lib/driver.js"],"sourcesContent":["import _ from 'lodash';\nimport path from 'path';\nimport B from 'bluebird';\nimport { BaseDriver, errors, isErrorType, DeviceSettings} from 'appium/driver';\nimport { EspressoRunner, TEST_APK_PKG } from './espresso-runner';\nimport { fs, tempDir, zip } from 'appium/support';\nimport commands from './commands';\nimport { DEFAULT_ADB_PORT } from 'appium-adb';\nimport { androidHelpers, androidCommands, SETTINGS_HELPER_PKG_ID } from 'appium-android-driver';\nimport desiredCapConstraints from './desired-caps';\nimport { findAPortNotInUse } from 'portscanner';\nimport { retryInterval } from 'asyncbox';\nimport { qualifyActivityName, getPackageInfo } from './utils';\n\n\n// TODO merge our own helpers onto this later\nconst helpers = androidHelpers;\n\n// The range of ports we can use on the system for communicating to the\n// Espresso HTTP server on the device\nconst SYSTEM_PORT_RANGE = [8300, 8399];\n\n// This is the port that the espresso server listens to on the device. We will\n// forward one of the ports above on the system to this port on the device.\nconst DEVICE_PORT = 6791;\n\n// NO_PROXY contains the paths that we never want to proxy to espresso server.\n// TODO: Add the list of paths that we never want to proxy to espresso server.\n// TODO: Need to segregate the paths better way using regular expressions wherever applicable.\n// (Not segregating right away because more paths to be added in the NO_PROXY list)\nconst NO_PROXY = [\n ['GET', new RegExp('^/session/(?!.*/)')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/current_activity')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/current_package')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/display_density')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/is_keyboard_shown')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/system_bars')],\n ['GET', new RegExp('^/session/[^/]+/appium/device/system_time')],\n ['GET', new RegExp('^/session/[^/]+/appium/settings')],\n ['GET', new RegExp('^/session/[^/]+/context')],\n ['GET', new RegExp('^/session/[^/]+/contexts')],\n ['GET', new RegExp('^/session/[^/]+/ime/[^/]+')],\n ['GET', new RegExp('^/session/[^/]+/network_connection')],\n ['GET', new RegExp('^/session/[^/]+/timeouts')],\n ['GET', new RegExp('^/session/[^/]+/url')],\n ['POST', new RegExp('^/session/[^/]+/appium/app/background')],\n ['POST', new RegExp('^/session/[^/]+/appium/app/close')],\n ['POST', new RegExp('^/session/[^/]+/appium/app/launch')],\n ['POST', new RegExp('^/session/[^/]+/appium/app/reset')],\n ['POST', new RegExp('^/session/[^/]+/appium/app/strings')],\n ['POST', new RegExp('^/session/[^/]+/appium/compare_images')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/activate_app')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/app_installed')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/app_state')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/finger_print')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/get_clipboard')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/install_app')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/is_locked')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/lock')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/pull_file')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/pull_folder')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/push_file')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/remove_app')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/start_activity')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/terminate_app')],\n ['POST', new RegExp('^/session/[^/]+/appium/device/unlock')],\n ['POST', new RegExp('^/session/[^/]+/appium/getPerformanceData')],\n ['POST', new RegExp('^/session/[^/]+/appium/performanceData/types')],\n ['POST', new RegExp('^/session/[^/]+/appium/settings')],\n ['POST', new RegExp('^/session/[^/]+/appium/execute_driver')],\n ['POST', new RegExp('^/session/[^/]+/appium/start_recording_screen')],\n ['POST', new RegExp('^/session/[^/]+/appium/stop_recording_screen')],\n ['POST', new RegExp('^/session/[^/]+/context')],\n ['POST', new RegExp('^/session/[^/]+/execute')],\n ['POST', new RegExp('^/session/[^/]+/execute/async')],\n ['POST', new RegExp('^/session/[^/]+/execute/sync')],\n ['POST', new RegExp('^/session/[^/]+/execute_async')],\n ['POST', new RegExp('^/session/[^/]+/ime/[^/]+')],\n ['POST', new RegExp('^/session/[^/]+/location')],\n ['POST', new RegExp('^/session/[^/]+/network_connection')],\n ['POST', new RegExp('^/session/[^/]+/timeouts')],\n ['POST', new RegExp('^/session/[^/]+/url')],\n\n // MJSONWP commands\n ['GET', new RegExp('^/session/[^/]+/log/types')],\n ['POST', new RegExp('^/session/[^/]+/log')],\n\n // W3C commands\n // For Selenium v4 (W3C does not have this route)\n ['GET', new RegExp('^/session/[^/]+/se/log/types')],\n // For Selenium v4 (W3C does not have this route)\n ['POST', new RegExp('^/session/[^/]+/se/log')],\n];\n\n// This is a set of methods and paths that we never want to proxy to Chromedriver.\nconst CHROME_NO_PROXY = [\n ['GET', new RegExp('^/session/[^/]+/appium')],\n ['GET', new RegExp('^/session/[^/]+/context')],\n ['GET', new RegExp('^/session/[^/]+/element/[^/]+/rect')],\n ['GET', new RegExp('^/session/[^/]+/orientation')],\n ['POST', new RegExp('^/session/[^/]+/appium')],\n ['POST', new RegExp('^/session/[^/]+/context')],\n ['POST', new RegExp('^/session/[^/]+/orientation')],\n ['POST', new RegExp('^/session/[^/]+/touch/multi/perform')],\n ['POST', new RegExp('^/session/[^/]+/touch/perform')],\n\n // this is needed to make the mobile: commands working in web context\n ['POST', new RegExp('^/session/[^/]+/execute$')],\n ['POST', new RegExp('^/session/[^/]+/execute/sync')],\n\n // MJSONWP commands\n ['GET', new RegExp('^/session/[^/]+/log/types')],\n ['POST', new RegExp('^/session/[^/]+/log')],\n\n // W3C commands\n // For Selenium v4 (W3C does not have this route)\n ['GET', new RegExp('^/session/[^/]+/se/log/types')],\n // For Selenium v4 (W3C does not have this route)\n ['POST', new RegExp('^/session/[^/]+/se/log')],\n];\n\n\nconst APK_EXT = '.apk';\nconst AAB_EXT = '.aab';\nconst SUPPORTED_EXTENSIONS = [APK_EXT, AAB_EXT];\n\nclass EspressoDriver extends BaseDriver {\n constructor (opts = {}, shouldValidateCaps = true) {\n // `shell` overwrites adb.shell, so remove\n delete opts.shell;\n\n super(opts, shouldValidateCaps);\n this.locatorStrategies = [\n 'id',\n 'class name',\n 'accessibility id',\n ];\n this.desiredCapConstraints = desiredCapConstraints;\n this.espresso = null;\n this.jwpProxyActive = false;\n this.defaultIME = null;\n this.jwpProxyAvoid = NO_PROXY;\n\n this.apkStrings = {}; // map of language -> strings obj\n this.settings = new DeviceSettings({}, this.onSettingsUpdate.bind(this));\n\n this.chromedriver = null;\n this.sessionChromedrivers = {};\n }\n\n async createSession (...args) {\n try {\n // TODO handle otherSessionData for multiple sessions\n let [sessionId, caps] = await super.createSession(...args);\n\n let serverDetails = {\n platform: 'LINUX',\n webStorageEnabled: false,\n takesScreenshot: true,\n javascriptEnabled: true,\n databaseEnabled: false,\n networkConnectionEnabled: true,\n locationContextEnabled: false,\n warnings: {},\n desired: Object.assign({}, this.caps)\n };\n\n this.caps = Object.assign(serverDetails, this.caps);\n\n this.curContext = this.defaultContextName();\n\n let defaultOpts = {\n fullReset: false,\n autoLaunch: true,\n adbPort: DEFAULT_ADB_PORT,\n androidInstallTimeout: 90000\n };\n _.defaults(this.opts, defaultOpts);\n\n if (this.isChromeSession) {\n if (this.opts.app) {\n this.log.warn(`'browserName' capability will be ignored`);\n this.log.warn(`Chrome browser cannot be run in Espresso sessions because Espresso automation doesn't ` +\n `have permission to access Chrome`);\n } else {\n this.log.errorAndThrow(`Chrome browser sessions cannot be run in Espresso because Espresso ` +\n `automation doesn't have permission to access Chrome`);\n }\n }\n\n if (this.opts.reboot) {\n this.setAvdFromCapabilities(caps);\n this.addWipeDataToAvdArgs();\n }\n\n this.opts.systemPort = this.opts.systemPort\n || await findAPortNotInUse(SYSTEM_PORT_RANGE[0], SYSTEM_PORT_RANGE[1]);\n this.opts.adbPort = this.opts.adbPort || DEFAULT_ADB_PORT;\n // get device udid for this session\n const {udid, emPort} = await helpers.getDeviceInfoFromCaps(this.opts);\n this.opts.udid = udid;\n this.opts.emPort = emPort;\n // now that we know our java version and device info, we can create our\n // ADB instance\n this.adb = await androidHelpers.createADB(this.opts);\n\n if (this.opts.app) {\n // find and copy, or download and unzip an app url or path\n this.opts.app = await this.helpers.configureApp(this.opts.app, {\n onPostProcess: this.onPostConfigureApp.bind(this),\n supportedExtensions: SUPPORTED_EXTENSIONS\n });\n } else if (this.appOnDevice) {\n // the app isn't an actual app file but rather something we want to\n // assume is on the device and just launch via the appPackage\n this.log.info(`App file was not listed, instead we're going to run ` +\n `${this.opts.appPackage} directly on the device`);\n if (!await this.adb.isAppInstalled(this.opts.appPackage)) {\n this.log.errorAndThrow(`Could not find the package '${this.opts.appPackage}' ` +\n `installed on the device`);\n }\n }\n\n await this.startEspressoSession();\n return [sessionId, caps];\n } catch (e) {\n await this.deleteSession();\n e.message += `${_.endsWith(e.message, '.') ? '' : '.'} Check ` +\n 'https://github.com/appium/appium-espresso-driver#troubleshooting ' +\n 'regarding advanced session startup troubleshooting.';\n if (isErrorType(e, errors.SessionNotCreatedError)) {\n throw e;\n }\n const err = new errors.SessionNotCreatedError(e.message);\n err.stack = e.stack;\n throw err;\n }\n }\n\n /**\n * Unzip the given app path and return the first package that has SUPPORTED_EXTENSIONS\n * in the archived file.\n *\n * @param {string} appPath The path to app file.\n * @returns {string} Retuns the path to an unzipped app file path.\n * @throws Raise an exception if the zip did not have any SUPPORTED_EXTENSIONS packages.\n */\n async unzipApp (appPath) {\n const useSystemUnzipEnv = process.env.APPIUM_PREFER_SYSTEM_UNZIP;\n const useSystemUnzip = _.isEmpty(useSystemUnzipEnv)\n || !['0', 'false'].includes(_.toLower(useSystemUnzipEnv));\n const tmpRoot = await tempDir.openDir();\n await zip.extractAllTo(appPath, tmpRoot, {useSystemUnzip});\n\n const globPattern = `**/*.+(${SUPPORTED_EXTENSIONS.map((ext) => ext.replace(/^\\./, '')).join('|')})`;\n const sortedBundleItems = (await fs.glob(globPattern, {\n cwd: tmpRoot,\n strict: false,\n })).sort((a, b) => a.split(path.sep).length - b.split(path.sep).length);\n if (sortedBundleItems.length === 0) {\n // no expected packages in the zip\n this.log.errorAndThrow(`${this.opts.app} did not have any of '${SUPPORTED_EXTENSIONS.join(', ')}' ` +\n `extension packages. Please make sure the provided .zip archive contains at least one valid application package.`);\n }\n const unzippedAppPath = path.join(tmpRoot, _.first(sortedBundleItems));\n this.log.debug(`'${unzippedAppPath}' is the unzipped file from '${appPath}'`);\n return unzippedAppPath;\n }\n\n async onPostConfigureApp ({cachedAppInfo, isUrl, appPath}) {\n const presignApp = async (appLocation) => {\n if (this.opts.noSign) {\n this.log.info('Skipping application signing because noSign capability is set to true. ' +\n 'Having the application under test with improper signature/non-signed will cause ' +\n 'Espresso automation startup failure.');\n } else if (!await this.adb.checkApkCert(appLocation, this.opts.appPackage)) {\n await this.adb.sign(appLocation, this.opts.appPackage);\n }\n };\n\n const hasApkExt = (appPath) => _.endsWith(_.toLower(appPath), APK_EXT);\n const hasAabExt = (appPath) => _.endsWith(_.toLower(appPath), AAB_EXT);\n const extractUniversalApk = async (shouldExtract, appPath) =>\n shouldExtract ? appPath : await this.adb.extractUniversalApk(appPath);\n\n let pathInCache = null;\n let isResultAppPathAlreadyCached = false;\n if (_.isPlainObject(cachedAppInfo)) {\n const packageHash = await fs.hash(appPath);\n if (packageHash === cachedAppInfo.packageHash && await fs.exists(cachedAppInfo.fullPath)) {\n this.log.info(`Using '${cachedAppInfo.fullPath}' which is cached from '${appPath}'`);\n isResultAppPathAlreadyCached = true;\n pathInCache = cachedAppInfo.fullPath;\n }\n }\n\n // appPath can be .zip, .apk or .aab\n const isApk = hasApkExt(appPath);\n // Only local .apk files that are available in-place should not be cached\n const shouldResultAppPathBeCached = !isApk || (isApk && isUrl);\n\n if (!isResultAppPathAlreadyCached) {\n if (shouldResultAppPathBeCached) {\n // .zip, .aab or downloaded .apk\n\n let unzippedAppPath;\n let isUnzippedApk = false;\n if (!(hasApkExt(appPath) || hasAabExt(appPath))) {\n unzippedAppPath = await this.unzipApp(appPath);\n isUnzippedApk = hasApkExt(unzippedAppPath);\n }\n\n // unzippedAppPath or appPath has SUPPORTED_EXTENSIONS.\n pathInCache = unzippedAppPath\n ? await extractUniversalApk(isUnzippedApk, unzippedAppPath)\n : await extractUniversalApk(isApk, appPath);\n\n if (!isApk && isUrl) {\n // Clean up the temporarily downloaded .aab or .zip package\n await fs.rimraf(appPath);\n }\n if (hasAabExt(unzippedAppPath)) {\n // Cleanup the local unzipped .aab file\n await fs.rimraf(unzippedAppPath);\n }\n await presignApp(pathInCache);\n } else if (isApk) {\n // It is probably not the best idea to modify the provided app in-place,\n // but this is how it was always working\n await presignApp(appPath);\n }\n }\n return shouldResultAppPathBeCached ? {appPath: pathInCache} : false;\n }\n\n get driverData () {\n // TODO fille out resource info here\n return {};\n }\n\n isEmulator () {\n return helpers.isEmulator(this.adb, this.opts);\n }\n\n // TODO this method is duplicated from uiautomator2-driver; consolidate\n setAvdFromCapabilities (caps) {\n if (this.opts.avd) {\n this.log.info('avd name defined, ignoring device name and platform version');\n } else {\n if (!caps.deviceName) {\n this.log.errorAndThrow('avd or deviceName should be specified when reboot option is enables');\n }\n if (!caps.platformVersion) {\n this.log.errorAndThrow('avd or platformVersion should be specified when reboot option is enabled');\n }\n let avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-');\n this.opts.avd = `${avdDevice}__${caps.platformVersion}`;\n }\n }\n\n // TODO this method is duplicated from uiautomator2-driver; consolidate\n addWipeDataToAvdArgs () {\n if (!this.opts.avdArgs) {\n this.opts.avdArgs = '-wipe-data';\n } else if (!this.opts.avdArgs.toLowerCase().includes('-wipe-data')) {\n this.opts.avdArgs += ' -wipe-data';\n }\n }\n\n // TODO much of this logic is duplicated from uiautomator2\n async startEspressoSession () {\n const {manifestPayload} = await getPackageInfo();\n this.log.info(`EspressoDriver version: ${manifestPayload.version}`);\n\n // Read https://github.com/appium/appium-android-driver/pull/461 what happens if ther is no setHiddenApiPolicy for Android P+\n if (await this.adb.getApiLevel() >= 28) { // Android P\n this.log.warn('Relaxing hidden api policy');\n await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);\n }\n\n // get appPackage et al from manifest if necessary\n let appInfo = await helpers.getLaunchInfo(this.adb, this.opts);\n if (appInfo) {\n // and get it onto our 'opts' object so we use it from now on\n Object.assign(this.opts, appInfo);\n } else {\n appInfo = this.opts;\n }\n\n // start an avd, set the language/locale, pick an emulator, etc...\n // TODO with multiple devices we'll need to parameterize this\n await helpers.initDevice(this.adb, this.opts);\n // https://github.com/appium/appium-espresso-driver/issues/72\n if (await this.adb.isAnimationOn()) {\n try {\n await this.adb.setAnimationState(false);\n this.wasAnimationEnabled = true;\n } catch (err) {\n this.log.warn(`Unable to turn off animations: ${err.message}`);\n }\n }\n\n // set actual device name, udid\n this.caps.deviceName = this.adb.curDeviceId;\n this.caps.deviceUDID = this.opts.udid;\n\n // set up the modified espresso server etc\n this.initEspressoServer();\n // Further prepare the device by forwarding the espresso port\n this.log.debug(`Forwarding Espresso Server port ${DEVICE_PORT} to ${this.opts.systemPort}`);\n await this.adb.forwardPort(this.opts.systemPort, DEVICE_PORT);\n\n if (!this.opts.skipUnlock) {\n // unlock the device to prepare it for testing\n await helpers.unlock(this, this.adb, this.caps);\n } else {\n this.log.debug(`'skipUnlock' capability set, so skipping device unlock`);\n }\n\n // set up app under test\n // prepare our actual AUT, get it on the device, etc...\n await this.initAUT();\n\n //Adding AUT package name in the capabilities if package name not exist in caps\n if (!this.caps.appPackage) {\n this.caps.appPackage = appInfo.appPackage;\n }\n if (!this.caps.appWaitPackage) {\n this.caps.appWaitPackage = appInfo.appWaitPackage || appInfo.appPackage || this.caps.appPackage;\n }\n if (this.caps.appActivity) {\n this.caps.appActivity = qualifyActivityName(this.caps.appActivity, this.caps.appPackage);\n } else {\n this.caps.appActivity = qualifyActivityName(appInfo.appActivity, this.caps.appPackage);\n }\n if (this.caps.appWaitActivity) {\n this.caps.appWaitActivity = qualifyActivityName(this.caps.appWaitActivity, this.caps.appWaitPackage);\n } else {\n this.caps.appWaitActivity = qualifyActivityName(appInfo.appWaitActivity || appInfo.appActivity || this.caps.appActivity,\n this.caps.appWaitPackage);\n }\n\n // launch espresso and wait till its online and we have a session\n await this.espresso.startSession(this.caps);\n if (this.caps.autoLaunch === false) {\n this.log.info(`Not waiting for the application activity to start because 'autoLaunch' is disabled`);\n } else {\n await this.adb.waitForActivity(this.caps.appWaitPackage, this.caps.appWaitActivity, this.opts.appWaitDuration);\n }\n // if we want to immediately get into a webview, set our context\n // appropriately\n if (this.opts.autoWebview) {\n await this.initWebview();\n }\n\n // now that everything has started successfully, turn on proxying so all\n // subsequent session requests go straight to/from espresso\n this.jwpProxyActive = true;\n\n await this.addDeviceInfoToCaps();\n }\n\n async initWebview () {\n const viewName = androidCommands.defaultWebviewName.call(this);\n const timeout = this.opts.autoWebviewTimeout || 2000;\n this.log.info(`Setting webview to context '${viewName}' with timeout ${timeout}ms`);\n await retryInterval(timeout / 500, 500, this.setContext.bind(this), viewName);\n }\n\n async addDeviceInfoToCaps () {\n const {\n apiVersion,\n platformVersion,\n manufacturer,\n model,\n realDisplaySize,\n displayDensity,\n } = await this.mobileGetDeviceInfo();\n this.caps.deviceApiLevel = parseInt(apiVersion, 10);\n this.caps.platformVersion = platformVersion;\n this.caps.deviceScreenSize = realDisplaySize;\n this.caps.deviceScreenDensity = displayDensity;\n this.caps.deviceModel = model;\n this.caps.deviceManufacturer = manufacturer;\n }\n\n initEspressoServer () {\n // now that we have package and activity, we can create an instance of\n // espresso with the appropriate data\n this.espresso = new EspressoRunner(this.log, {\n host: this.opts.remoteAdbHost || this.opts.host || '127.0.0.1',\n systemPort: this.opts.systemPort,\n devicePort: DEVICE_PORT,\n adb: this.adb,\n apk: this.opts.app,\n tmpDir: this.opts.tmpDir,\n appPackage: this.opts.appPackage,\n appActivity: this.opts.appActivity,\n forceEspressoRebuild: !!this.opts.forceEspressoRebuild,\n espressoBuildConfig: this.opts.espressoBuildConfig,\n showGradleLog: !!this.opts.showGradleLog,\n serverLaunchTimeout: this.opts.espressoServerLaunchTimeout,\n androidInstallTimeout: this.opts.androidInstallTimeout,\n skipServerInstallation: this.opts.skipServerInstallation,\n useKeystore: this.opts.useKeystore,\n keystorePath: this.opts.keystorePath,\n keystorePassword: this.opts.keystorePassword,\n keyAlias: this.opts.keyAlias,\n keyPassword: this.opts.keyPassword,\n disableSuppressAccessibilityService: this.opts.disableSuppressAccessibilityService,\n });\n this.proxyReqRes = this.espresso.proxyReqRes.bind(this.espresso);\n this.proxyCommand = this.espresso.proxyCommand.bind(this.espresso);\n }\n\n // TODO this method is mostly duplicated from uiautomator2\n async initAUT () {\n // set the localized strings for the current language from the apk\n // TODO: incorporate changes from appium#5308 which fix a race cond-\n // ition bug in old appium and need to be replicated here\n // this.apkStrings[this.opts.language] = await androidHelpers.pushStrings(\n // this.opts.language, this.adb, this.opts);\n\n // Uninstall any uninstallOtherPackages which were specified in caps\n if (this.opts.uninstallOtherPackages) {\n await helpers.uninstallOtherPackages(\n this.adb,\n helpers.parseArray(this.opts.uninstallOtherPackages),\n [SETTINGS_HELPER_PKG_ID, TEST_APK_PKG]\n );\n }\n\n if (!this.opts.app) {\n if (this.opts.fullReset) {\n this.log.errorAndThrow('Full reset requires an app capability, use fastReset if app is not provided');\n }\n this.log.debug('No app capability. Assuming it is already on the device');\n if (this.opts.fastReset) {\n await helpers.resetApp(this.adb, this.opts);\n }\n }\n\n if (!this.opts.skipUninstall) {\n await this.adb.uninstallApk(this.opts.appPackage);\n }\n if (this.opts.app) {\n await helpers.installApk(this.adb, this.opts);\n }\n if (this.opts.skipServerInstallation) {\n this.log.debug('skipServerInstallation capability is set. Not installig espresso-server ');\n } else {\n await this.espresso.installTestApk();\n try {\n await this.adb.addToDeviceIdleWhitelist(SETTINGS_HELPER_PKG_ID, TEST_APK_PKG);\n } catch (e) {\n this.log.warn(`Cannot add server packages to the Doze whitelist. Original error: ` +\n (e.stderr || e.message));\n }\n }\n }\n\n async deleteSession () {\n this.log.debug('Deleting espresso session');\n\n const screenRecordingStopTasks = [async () => {\n if (!_.isEmpty(this._screenRecordingProperties)) {\n await this.stopRecordingScreen();\n }\n }, async () => {\n if (await this.mobileIsMediaProjectionRecordingRunning()) {\n await this.mobileStopMediaProjectionRecording();\n }\n }, async () => {\n if (!_.isEmpty(this._screenStreamingProps)) {\n await this.mobileStopScreenStreaming();\n }\n }];\n\n await androidHelpers.removeAllSessionWebSocketHandlers(this.server, this.sessionId);\n\n if (this.espresso) {\n if (this.jwpProxyActive) {\n await this.espresso.deleteSession();\n }\n this.espresso = null;\n }\n this.jwpProxyActive = false;\n\n if (this.adb) {\n await B.all(screenRecordingStopTasks.map((task) => {\n (async () => {\n try {\n await task();\n } catch (ign) {}\n })();\n }));\n if (this.wasAnimationEnabled) {\n try {\n await this.adb.setAnimationState(true);\n } catch (err) {\n this.log.warn(`Unable to reset animation: ${err.message}`);\n }\n }\n if (this.opts.unicodeKeyboard && this.opts.resetKeyboard &&\n this.defaultIME) {\n this.log.debug(`Resetting IME to '${this.defaultIME}'`);\n await this.adb.setIME(this.defaultIME);\n }\n if (!this.isChromeSession && this.opts.appPackage && !this.opts.dontStopAppOnReset) {\n await this.adb.forceStop(this.opts.appPackage);\n }\n if (this.opts.fullReset && !this.opts.skipUninstall && !this.appOnDevice) {\n this.log.debug(`FULL_RESET set to 'true', Uninstalling '${this.opts.appPackage}'`);\n await this.adb.uninstallApk(this.opts.appPackage);\n }\n await this.adb.stopLogcat();\n if (this.opts.reboot) {\n let avdName = this.opts.avd.replace('@', '');\n this.log.debug(`closing emulator '${avdName}'`);\n await this.adb.killEmulator(avdName);\n }\n if (await this.adb.getApiLevel() >= 28) { // Android P\n this.log.info('Restoring hidden api policy to the device default configuration');\n await this.adb.setDefaultHiddenApiPolicy(!!this.opts.ignoreHiddenApiPolicyError);\n }\n }\n await super.deleteSession();\n if (this.opts.systemPort !== undefined) {\n try {\n await this.adb.removePortForward(this.opts.systemPort);\n } catch (error) {\n this.log.warn(`Unable to remove port forward '${error.message}'`);\n //Ignore, this block will also be called when we fall in catch block\n // and before even port forward.\n }\n }\n }\n\n async onSettingsUpdate () {\n // intentionally do nothing here, since commands.updateSettings proxies\n // settings to the espresso server already\n }\n\n proxyActive (sessionId) {\n super.proxyActive(sessionId);\n\n // we always have an active proxy to the espresso server\n return true;\n }\n\n canProxy (sessionId) {\n super.canProxy(sessionId);\n\n // we can always proxy to the espresso server\n return true;\n }\n\n getProxyAvoidList (sessionId) {\n super.getProxyAvoidList(sessionId);\n // we are maintaining two sets of NO_PROXY lists, one for chromedriver(CHROME_NO_PROXY)\n // and one for Espresso(NO_PROXY), based on current context will return related NO_PROXY list\n this.jwpProxyAvoid = _.isNil(this.chromedriver) ? NO_PROXY : CHROME_NO_PROXY;\n if (this.opts.nativeWebScreenshot) {\n this.jwpProxyAvoid = [...this.jwpProxyAvoid, ['GET', new RegExp('^/session/[^/]+/screenshot')]];\n }\n\n return this.jwpProxyAvoid;\n }\n\n get isChromeSession () {\n return helpers.isChromeBrowser(this.opts.browserName);\n }\n\n get appOnDevice () {\n return !this.opts.app && this.helpers.isPackageOrBundle(this.opts.appPackage);\n }\n}\n\n// first add the android-driver commands which we will fall back to\nfor (let [cmd, fn] of _.toPairs(androidCommands)) {\n // we do some different/special things with these methods\n if (!_.includes(['defaultWebviewName'], cmd)) {\n EspressoDriver.prototype[cmd] = fn;\n }\n}\n\n// then overwrite with any espresso-specific commands\nfor (let [cmd, fn] of _.toPairs(commands)) {\n EspressoDriver.prototype[cmd] = fn;\n}\n\nexport { EspressoDriver };\nexport default EspressoDriver;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA,MAAMA,OAAO,GAAGC,mCAAhB;AAIA,MAAMC,iBAAiB,GAAG,CAAC,IAAD,EAAO,IAAP,CAA1B;AAIA,MAAMC,WAAW,GAAG,IAApB;AAMA,MAAMC,QAAQ,GAAG,CACf,CAAC,KAAD,EAAQ,IAAIC,MAAJ,CAAW,mBAAX,CAAR,CADe,EAEf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,gDAAX,CAAR,CAFe,EAGf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,+CAAX,CAAR,CAHe,EAIf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,+CAAX,CAAR,CAJe,EAKf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,iDAAX,CAAR,CALe,EAMf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,2CAAX,CAAR,CANe,EAOf,CAAC,KAAD,EAAQ,IAAIA,MAAJ,CAAW,2CAAX,CAAR,CAPe,EAQf,CAAC,KAAD,EA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C;;;;AAyiBxC,KAAK,IAAI,CAAC+L,GAAD,EAAMC,EAAN,CAAT,IAAsBvN,eAAA,CAAEwN,OAAF,CAAUtF,oCAAV,CAAtB,EAAkD;EAEhD,IAAI,CAAClI,eAAA,CAAE2C,QAAF,CAAW,CAAC,oBAAD,CAAX,EAAmC2K,GAAnC,CAAL,EAA8C;IAC5CjQ,cAAc,CAACoQ,SAAf,CAAyBH,GAAzB,IAAgCC,EAAhC;EACD;AACF;;AAGD,KAAK,IAAI,CAACD,GAAD,EAAMC,EAAN,CAAT,IAAsBvN,eAAA,CAAEwN,OAAF,CAAUE,iBAAV,CAAtB,EAA2C;EACzCrQ,cAAc,CAACoQ,SAAf,CAAyBH,GAAzB,IAAgCC,EAAhC;AACD;;eAGclQ,c"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"espresso-runner.js","names":["TEST_SERVER_ROOT","path","resolve","__dirname","TEST_APK_PKG","REQUIRED_PARAMS","ESPRESSO_SERVER_LAUNCH_TIMEOUT_MS","TARGET_PACKAGE_CONTAINER","EspressoProxy","JWProxy","proxyCommand","url","method","body","crashed","exited","instrumentationState","errors","InvalidContextError","EspressoRunner","constructor","log","opts","req","util","hasValue","Error","jwproxy","server","host","port","systemPort","base","keepAlive","proxyReqRes","bind","command","manifestPayload","getPackageInfoSync","modServerName","fs","sanitizeName","version","appPackage","adb","curDeviceId","replacement","modServerPath","tmpDir","showGradleLog","espressoBuildConfig","serverLaunchTimeout","androidInstallTimeout","disableSuppressAccessibilityService","useKeystore","keystorePath","keystorePassword","keyAlias","keyPassword","signingConfig","buildServerSigningConfig","keystoreFile","isAppPackageChanged","fileExists","debug","previousAppPackage","shell","trim","installServer","appState","getApplicationInstallState","shouldUninstallApp","APP_INSTALL_STATE","OLDER_VERSION_INSTALLED","NEWER_VERSION_INSTALLED","includes","shouldInstallApp","NOT_INSTALLED","info","uninstallApk","err","warn","message","install","replace","timeout","errorAndThrow","installTestApk","rebuild","forceEspressoRebuild","exists","unlink","buildNewModServer","isSigned","checkApkCert","sign","buildConfiguration","buildConfigurationStr","readFile","JSON","parse","e","error","dirName","serverPath","rimraf","mkdirp","copyGradleProjectRecursively","ServerBuilder","testAppPackage","build","apkPath","copyFile","cleanupSessionLeftovers","value","axios","data","activeSessionIds","map","sess","id","length","stringify","B","all","delay","startSession","caps","cmd","process","env","ESPRESSO_JAVA_DEBUG","_","isBoolean","push","getPackageInfo","join","hasSocketError","instProcess","createSubProcess","on","code","signal","stdout","stderr","line","isEmpty","toLowerCase","timer","timing","Timer","start","waitForCondition","waitMs","intervalMs","test","getDuration","asMilliSeconds","toFixed","capabilities","firstMatch","alwaysMatch","recordTargetAppPackage","deleteSession","isRunning","stop"],"sources":["../../lib/espresso-runner.js"],"sourcesContent":["import { JWProxy, errors } from 'appium/driver';\nimport { waitForCondition } from 'asyncbox';\nimport { ServerBuilder, buildServerSigningConfig } from './server-builder';\nimport path from 'path';\nimport { fs, util, mkdirp, timing } from 'appium/support';\nimport B from 'bluebird';\nimport _ from 'lodash';\nimport { copyGradleProjectRecursively, getPackageInfoSync, getPackageInfo } from './utils';\nimport axios from 'axios';\n\n\nconst TEST_SERVER_ROOT = path.resolve(__dirname, '..', '..', 'espresso-server');\nconst TEST_APK_PKG = 'io.appium.espressoserver.test';\nconst REQUIRED_PARAMS = [\n 'adb',\n 'tmpDir',\n 'host',\n 'systemPort',\n 'devicePort',\n 'appPackage',\n 'forceEspressoRebuild',\n];\nconst ESPRESSO_SERVER_LAUNCH_TIMEOUT_MS = 45000;\nconst TARGET_PACKAGE_CONTAINER = '/data/local/tmp/espresso.apppackage';\n\nclass EspressoProxy extends JWProxy {\n async proxyCommand (url, method, body = null) {\n const {crashed, exited} = this.instrumentationState;\n if (exited) {\n throw new errors.InvalidContextError(`'${method} ${url}' cannot be proxied to Espresso server because ` +\n `the instrumentation process has ${crashed ? 'crashed' : 'been unexpectedly terminated'}. ` +\n `Check the Appium server log and the logcat output for more details`);\n }\n return await super.proxyCommand(url, method, body);\n }\n}\n\nclass EspressoRunner {\n constructor (log, opts = {}) {\n for (let req of REQUIRED_PARAMS) {\n if (!opts || !util.hasValue(opts[req])) {\n throw new Error(`Option '${req}' is required!`);\n }\n this[req] = opts[req];\n }\n this.log = log;\n this.jwproxy = new EspressoProxy({\n log,\n server: this.host,\n port: this.systemPort,\n base: '',\n keepAlive: true,\n });\n this.proxyReqRes = this.jwproxy.proxyReqRes.bind(this.jwproxy);\n this.proxyCommand = this.jwproxy.command.bind(this.jwproxy);\n this.jwproxy.instrumentationState = {\n exited: false,\n crashed: false,\n };\n\n const { manifestPayload } = getPackageInfoSync();\n const modServerName = fs.sanitizeName(\n `${TEST_APK_PKG}_${manifestPayload.version}_${this.appPackage}_${this.adb.curDeviceId}.apk`,\n {replacement: '-'}\n );\n this.modServerPath = path.resolve(this.tmpDir, modServerName);\n this.showGradleLog = opts.showGradleLog;\n this.espressoBuildConfig = opts.espressoBuildConfig;\n\n this.serverLaunchTimeout = opts.serverLaunchTimeout || ESPRESSO_SERVER_LAUNCH_TIMEOUT_MS;\n this.androidInstallTimeout = opts.androidInstallTimeout;\n\n this.disableSuppressAccessibilityService = opts.disableSuppressAccessibilityService;\n\n // Espresso Server app needs to be signed with same keyStore as appPackage\n if (opts.useKeystore && opts.keystorePath && opts.keystorePassword && opts.keyAlias && opts.keyPassword) {\n this.signingConfig = buildServerSigningConfig({\n keystoreFile: opts.keystorePath,\n keystorePassword: opts.keystorePassword,\n keyAlias: opts.keyAlias,\n keyPassword: opts.keyPassword\n });\n } else {\n this.signingConfig = null;\n }\n }\n\n async isAppPackageChanged () {\n if (!await this.adb.fileExists(TARGET_PACKAGE_CONTAINER)) {\n this.log.debug('The previous target application package is unknown');\n return true;\n }\n const previousAppPackage = (await this.adb.shell(['cat', TARGET_PACKAGE_CONTAINER])).trim();\n this.log.debug(`The previous target application package was '${previousAppPackage}'. ` +\n `The current package is '${this.appPackage}'`);\n return previousAppPackage !== this.appPackage;\n }\n\n /**\n * Installs Espresso server apk on to the device or emulator.\n * Each adb command uses default timeout by them.\n */\n async installServer () {\n const appState = await this.adb.getApplicationInstallState(this.modServerPath, TEST_APK_PKG);\n\n const shouldUninstallApp = [\n this.adb.APP_INSTALL_STATE.OLDER_VERSION_INSTALLED,\n this.adb.APP_INSTALL_STATE.NEWER_VERSION_INSTALLED\n ].includes(appState);\n const shouldInstallApp = shouldUninstallApp || [\n this.adb.APP_INSTALL_STATE.NOT_INSTALLED\n ].includes(appState);\n\n if (shouldUninstallApp) {\n this.log.info(`Uninstalling Espresso Test Server apk from the target device (pkg: '${TEST_APK_PKG}')`);\n try {\n await this.adb.uninstallApk(TEST_APK_PKG);\n } catch (err) {\n this.log.warn(`Error uninstalling '${TEST_APK_PKG}': ${err.message}`);\n }\n }\n\n if (shouldInstallApp) {\n this.log.info(`Installing Espresso Test Server apk from the target device (path: '${this.modServerPath}')`);\n try {\n await this.adb.install(this.modServerPath, { replace: false, timeout: this.androidInstallTimeout });\n this.log.info(`Installed Espresso Test Server apk '${this.modServerPath}' (pkg: '${TEST_APK_PKG}')`);\n } catch (err) {\n this.log.errorAndThrow(`Cannot install '${this.modServerPath}' because of '${err.message}'`);\n }\n }\n }\n\n async installTestApk () {\n let rebuild = this.forceEspressoRebuild;\n if (rebuild) {\n this.log.debug(`'forceEspressoRebuild' capability is enabled`);\n } else if (await this.isAppPackageChanged()) {\n this.log.info(`Forcing Espresso server rebuild because of changed application package`);\n rebuild = true;\n }\n\n if (rebuild && await fs.exists(this.modServerPath)) {\n this.log.debug(`Deleting the obsolete Espresso server package '${this.modServerPath}'`);\n await fs.unlink(this.modServerPath);\n }\n if (!(await fs.exists(this.modServerPath))) {\n await this.buildNewModServer();\n }\n const isSigned = await this.adb.checkApkCert(this.modServerPath, TEST_APK_PKG);\n if (!isSigned) {\n await this.adb.sign(this.modServerPath);\n }\n if ((rebuild || !isSigned) && await this.adb.uninstallApk(TEST_APK_PKG)) {\n this.log.info('Uninstalled the obsolete Espresso server package from the device under test');\n }\n\n await this.installServer();\n }\n\n async buildNewModServer () {\n let buildConfiguration = {};\n if (this.espressoBuildConfig) {\n let buildConfigurationStr;\n if (await fs.exists(this.espressoBuildConfig)) {\n this.log.info(`Loading the build configuration from '${this.espressoBuildConfig}'`);\n buildConfigurationStr = await fs.readFile(this.espressoBuildConfig, 'utf8');\n } else {\n this.log.info(`Loading the build configuration from 'espressoBuildConfig' capability`);\n buildConfigurationStr = this.espressoBuildConfig;\n }\n try {\n buildConfiguration = JSON.parse(buildConfigurationStr);\n } catch (e) {\n this.log.error('Cannot parse the build configuration JSON', e);\n throw e;\n }\n }\n const dirName = fs.sanitizeName(`espresso-server-${this.adb.curDeviceId}`, {\n replacement: '-',\n });\n const serverPath = path.resolve(this.tmpDir, dirName);\n this.log.info(`Building espresso server in '${serverPath}'`);\n this.log.debug(`The build folder root could be customized by changing the 'tmpDir' capability`);\n await fs.rimraf(serverPath);\n await mkdirp(serverPath);\n this.log.debug(`Copying espresso server template from ('${TEST_SERVER_ROOT}' to '${serverPath}')`);\n await copyGradleProjectRecursively(TEST_SERVER_ROOT, serverPath);\n this.log.debug('Bulding espresso server');\n await new ServerBuilder(this.log, {\n serverPath, buildConfiguration,\n showGradleLog: this.showGradleLog,\n testAppPackage: this.appPackage,\n signingConfig: this.signingConfig\n }).build();\n const apkPath = path.resolve(serverPath, 'app', 'build', 'outputs', 'apk', 'androidTest', 'debug', 'app-debug-androidTest.apk');\n this.log.debug(`Copying built apk from '${apkPath}' to '${this.modServerPath}'`);\n await fs.copyFile(apkPath, this.modServerPath);\n }\n\n async cleanupSessionLeftovers () {\n this.log.debug('Performing cleanup of automation leftovers');\n\n try {\n const {value} = (await axios({\n url: `http://${this.host}:${this.systemPort}/sessions`,\n timeout: 500,\n })).data;\n const activeSessionIds = value.map((sess) => sess.id);\n if (activeSessionIds.length) {\n this.log.debug(`The following obsolete sessions are still running: ${JSON.stringify(activeSessionIds)}`);\n this.log.debug('Cleaning up the obsolete sessions');\n await B.all(activeSessionIds.map((id) =>\n axios({\n url: `http://${this.host}:${this.systemPort}/session/${id}`,\n method: 'DELETE',\n })\n ));\n // Let all sessions to be properly terminated before continuing\n await B.delay(1000);\n } else {\n this.log.debug('No obsolete sessions have been detected');\n }\n } catch (e) {\n this.log.debug(`No obsolete sessions have been detected (${e.message})`);\n }\n }\n\n async startSession (caps) {\n await this.cleanupSessionLeftovers();\n\n const cmd = [\n 'shell',\n 'am', 'instrument',\n '-w',\n '-e', 'debug', process.env.ESPRESSO_JAVA_DEBUG === 'true',\n '-e', 'disableAnalytics', true, // To avoid unexpected error by google analytics\n ];\n\n if (_.isBoolean(this.disableSuppressAccessibilityService)) {\n cmd.push('-e', 'DISABLE_SUPPRESS_ACCESSIBILITY_SERVICES', this.disableSuppressAccessibilityService);\n }\n\n cmd.push(`${TEST_APK_PKG}/androidx.test.runner.AndroidJUnitRunner`);\n\n const {manifestPayload} = await getPackageInfo();\n this.log.info(`Starting Espresso Server v${manifestPayload.version} with cmd: adb ${cmd.join(' ')}`);\n\n let hasSocketError = false;\n // start the instrumentation process\n this.jwproxy.instrumentationState = {\n exited: false,\n crashed: false,\n };\n this.instProcess = this.adb.createSubProcess(cmd);\n this.instProcess.on('exit', (code, signal) => {\n this.log.info(`Instrumentation process exited with code ${code} from signal ${signal}`);\n this.jwproxy.instrumentationState.exited = true;\n });\n this.instProcess.on('output', (stdout, stderr) => {\n const line = stdout || stderr;\n if (_.isEmpty(line.trim())) {\n // Do not print empty lines into the system log\n return;\n }\n\n this.log.debug(`[Instrumentation] ${line.trim()}`);\n // A 'SocketException' indicates that we couldn't connect to the Espresso server,\n // because the INTERNET permission is not set\n if (line.toLowerCase().includes('java.net.socketexception')) {\n hasSocketError = true;\n } else if (line.includes('Process crashed')) {\n this.jwproxy.instrumentationState.crashed = true;\n }\n });\n\n const timer = new timing.Timer().start();\n await this.instProcess.start(0);\n this.log.info(`Waiting up to ${this.serverLaunchTimeout}ms for Espresso server to be online`);\n try {\n await waitForCondition(async () => {\n if (hasSocketError) {\n this.log.errorAndThrow(`Espresso server has failed to start due to an unexpected exception. ` +\n `Make sure the 'INTERNET' permission is requested in the Android manifest of your ` +\n `application under test (<uses-permission android:name=\"android.permission.INTERNET\" />)`);\n } else if (this.jwproxy.instrumentationState.exited) {\n this.log.errorAndThrow(`Espresso server process has been unexpectedly terminated. ` +\n `Check the Appium server log and the logcat output for more details`);\n }\n try {\n await this.jwproxy.command('/status', 'GET');\n return true;\n } catch (e) {\n return false;\n }\n }, {\n waitMs: this.serverLaunchTimeout,\n intervalMs: 500,\n });\n } catch (e) {\n if (/Condition unmet/.test(e.message)) {\n this.log.errorAndThrow(`Timed out waiting for Espresso server to be ` +\n `online within ${this.serverLaunchTimeout}ms. The timeout value could be ` +\n `customized using 'espressoServerLaunchTimeout' capability`);\n }\n throw e;\n }\n this.log.info(`Espresso server is online. ` +\n `The initialization process took ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);\n this.log.info('Starting the session');\n\n await this.jwproxy.command('/session', 'POST', {\n capabilities: {\n firstMatch: [caps],\n alwaysMatch: {}\n }\n });\n await this.recordTargetAppPackage();\n }\n\n async recordTargetAppPackage () {\n await this.adb.shell([`echo \"${this.appPackage}\" > \"${TARGET_PACKAGE_CONTAINER}\"`]);\n this.log.info(`Recorded the target application package '${this.appPackage}' to ${TARGET_PACKAGE_CONTAINER}`);\n }\n\n async deleteSession () {\n this.log.debug('Deleting Espresso server session');\n // rely on jwproxy's intelligence to know what we're talking about and\n // delete the current session\n try {\n await this.jwproxy.command('/', 'DELETE');\n } catch (err) {\n this.log.warn(`Did not get confirmation Espresso deleteSession worked; ` +\n `Error was: ${err}`);\n }\n\n if (this.instProcess && this.instProcess.isRunning) {\n await this.instProcess.stop();\n }\n }\n}\n\nexport { EspressoRunner, REQUIRED_PARAMS, TEST_APK_PKG };\nexport default EspressoRunner;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA,MA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sourcesContent":["import { logger } from 'appium/support';\n\n\nconst log = logger.getLogger('Espresso');\n\nexport default log;\n"],"mappings":";;;;;;;;;AAAA;;AAGA,MAAMA,GAAG,GAAGC,eAAA,CAAOC,SAAP,CAAiB,UAAjB,CAAZ;;eAEeF,G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-builder.js","names":["GRADLE_VERSION_KEY","GRADLE_URL_PREFIX","GRADLE_URL_TEMPLATE","GRADLE_MAX_ERROR_LOG_LINES","DEPENDENCY_PROP_NAMES","VERSION_KEYS","buildServerSigningConfig","args","zipAlign","keystoreFile","keystorePassword","keyAlias","keyPassword","ServerBuilder","constructor","log","serverPath","showGradleLog","buildConfiguration","versionConfiguration","toolsVersions","serverVersions","_","reduce","acc","value","key","includes","warn","testAppPackage","signingConfig","propName","build","setGradleWrapperVersion","insertAdditionalDependencies","runBuildProcess","getCommand","cmd","system","isWindows","path","resolve","buildProperty","filter","map","serverVersion","gradleProperty","charAt","toUpperCase","slice","Boolean","push","keys","upperFirst","k","v","version","propertiesPath","originalProperties","fs","readFile","newProperties","updateGradleDistUrl","writeFile","propertiesContent","replace","RegExp","escapeRegExp","hasAdditionalDeps","isArray","Error","isEmpty","line","trim","dep","test","buildPath","configuration","prefix","deps","info","updateDependencyLines","debug","join","gradlebuild","SubProcess","cwd","stdio","windowsVerbatimArguments","buildLastLines","logMsg","on","startsWith","EOL","length","start","err","msg","message","errorAndThrow"],"sources":["../../lib/server-builder.js"],"sourcesContent":["import { SubProcess } from 'teen_process';\nimport { fs, system } from 'appium/support';\nimport _ from 'lodash';\nimport path from 'path';\nimport { EOL } from 'os';\nimport { updateDependencyLines } from './utils';\n\nconst GRADLE_VERSION_KEY = 'gradle';\nconst GRADLE_URL_PREFIX = 'distributionUrl=';\nconst GRADLE_URL_TEMPLATE = 'https\\\\://services.gradle.org/distributions/gradle-VERSION-all.zip';\nconst GRADLE_MAX_ERROR_LOG_LINES = 15;\nconst DEPENDENCY_PROP_NAMES = ['additionalAppDependencies', 'additionalAndroidTestDependencies'];\n\nconst VERSION_KEYS = [\n GRADLE_VERSION_KEY,\n 'androidGradlePlugin',\n 'compileSdk',\n 'buildTools',\n 'minSdk',\n 'targetSdk',\n 'kotlin',\n 'sourceCompatibility',\n 'targetCompatibility',\n 'jvmTarget',\n 'composeVersion',\n 'annotationVersion'\n];\n\nfunction buildServerSigningConfig (args) {\n return {\n zipAlign: true,\n keystoreFile: args.keystoreFile,\n keystorePassword: args.keystorePassword,\n keyAlias: args.keyAlias,\n keyPassword: args.keyPassword\n };\n}\n\nclass ServerBuilder {\n constructor (log, args = {}) {\n this.log = log;\n this.serverPath = args.serverPath;\n this.showGradleLog = args.showGradleLog;\n\n const buildConfiguration = args.buildConfiguration || {};\n\n const versionConfiguration = buildConfiguration.toolsVersions || {};\n this.serverVersions = _.reduce(versionConfiguration, (acc, value, key) => {\n if (VERSION_KEYS.includes(key)) {\n acc[key] = value;\n } else {\n log.warn(`Got unexpected '${key}' in toolsVersion block of the build configuration`);\n }\n return acc;\n }, {});\n\n this.testAppPackage = args.testAppPackage;\n this.signingConfig = args.signingConfig;\n\n for (const propName of DEPENDENCY_PROP_NAMES) {\n this[propName] = buildConfiguration[propName] || [];\n }\n }\n\n async build () {\n if (this.serverVersions[GRADLE_VERSION_KEY]) {\n await this.setGradleWrapperVersion(this.serverVersions[GRADLE_VERSION_KEY]);\n }\n\n await this.insertAdditionalDependencies();\n\n await this.runBuildProcess();\n }\n\n getCommand () {\n const cmd = system.isWindows() ? 'gradlew.bat' : path.resolve(this.serverPath, 'gradlew');\n const buildProperty = (key, value) => value ? `-P${key}=${value}` : null;\n let args = VERSION_KEYS\n .filter((key) => key !== GRADLE_VERSION_KEY)\n .map((key) => {\n const serverVersion = this.serverVersions[key];\n const gradleProperty = `appium${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n return buildProperty(gradleProperty, serverVersion);\n })\n .filter(Boolean);\n\n if (this.signingConfig) {\n args.push(...(\n _.keys(this.signingConfig)\n .map((key) => [`appium${_.upperFirst(key)}`, this.signingConfig[key]])\n .map(([k, v]) => buildProperty(k, v))\n .filter(Boolean)\n ));\n }\n\n if (this.testAppPackage) {\n args.push(buildProperty('appiumTargetPackage', this.testAppPackage));\n }\n args.push('app:assembleAndroidTest');\n\n return {cmd, args};\n }\n\n async setGradleWrapperVersion (version) {\n const propertiesPath = path.resolve(this.serverPath, 'gradle', 'wrapper', 'gradle-wrapper.properties');\n const originalProperties = await fs.readFile(propertiesPath, 'utf8');\n const newProperties = this.updateGradleDistUrl(originalProperties, version);\n await fs.writeFile(propertiesPath, newProperties, 'utf8');\n }\n\n updateGradleDistUrl (propertiesContent, version) {\n return propertiesContent.replace(\n new RegExp(`^(${_.escapeRegExp(GRADLE_URL_PREFIX)}).+$`, 'gm'),\n `$1${GRADLE_URL_TEMPLATE.replace('VERSION', version)}`\n );\n }\n\n async insertAdditionalDependencies () {\n let hasAdditionalDeps = false;\n for (const propName of DEPENDENCY_PROP_NAMES) {\n if (!_.isArray(this[propName])) {\n throw new Error(`'${propName}' must be an array`);\n }\n if (_.isEmpty(this[propName].filter((line) => _.trim(line)))) {\n continue;\n }\n\n for (const dep of this[propName]) {\n if (/[\\s'\\\\$]/.test(dep)) {\n throw new Error('Single quotes, dollar characters and whitespace characters' +\n ` are disallowed in additional dependencies: ${dep}`);\n }\n }\n hasAdditionalDeps = true;\n }\n if (!hasAdditionalDeps) {\n return;\n }\n\n const buildPath = path.resolve(this.serverPath, 'app', 'build.gradle.kts');\n let configuration = await fs.readFile(buildPath, 'utf8');\n for (const propName of DEPENDENCY_PROP_NAMES) {\n const prefix = propName === DEPENDENCY_PROP_NAMES[0]\n ? 'implementation'\n : 'androidTestImplementation';\n const deps = this[propName]\n .filter((line) => _.trim(line))\n .map((line) => `${prefix}(\"${line}\")`);\n if (_.isEmpty(deps)) {\n continue;\n }\n\n this.log.info(`Adding the following ${propName} to build.gradle.kts: ${deps}`);\n configuration = updateDependencyLines(configuration, propName, deps);\n }\n await fs.writeFile(buildPath, configuration, 'utf8');\n }\n\n async runBuildProcess () {\n const {cmd, args} = this.getCommand();\n this.log.debug(`Beginning build with command '${cmd} ${args.join(' ')}' ` +\n `in directory '${this.serverPath}'`);\n const gradlebuild = new SubProcess(cmd, args, {\n cwd: this.serverPath,\n stdio: ['ignore', 'pipe', 'pipe'],\n windowsVerbatimArguments: true\n });\n let buildLastLines = [];\n\n const logMsg = `Output from Gradle ${this.showGradleLog ? 'will' : 'will not'} be logged`;\n this.log.debug(`${logMsg}. To change this, use 'showGradleLog' desired capability`);\n gradlebuild.on('stream-line', (line) => {\n if (this.showGradleLog) {\n if (line.startsWith('[STDERR]')) {\n this.log.warn(`[Gradle] ${line}`);\n } else {\n this.log.info(`[Gradle] ${line}`);\n }\n }\n buildLastLines.push(`${EOL}${line}`);\n if (buildLastLines.length > GRADLE_MAX_ERROR_LOG_LINES) {\n buildLastLines = buildLastLines.slice(-GRADLE_MAX_ERROR_LOG_LINES);\n }\n });\n\n try {\n await gradlebuild.start();\n await gradlebuild.join();\n } catch (err) {\n let msg = `Unable to build Espresso server - ${err.message}\\n` +\n `Gradle error message:${EOL}${buildLastLines}`;\n this.log.errorAndThrow(msg);\n }\n }\n}\n\nexport { ServerBuilder, VERSION_KEYS, GRADLE_URL_TEMPLATE, buildServerSigningConfig };\nexport default ServerBuilder;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,kBAAkB,GAAG,QAA3B;AACA,MAAMC,iBAAiB,GAAG,kBAA1B;AACA,MAAMC,mBAAmB,GAAG,oEAA5B;;AACA,MAAMC,0BAA0B,GAAG,EAAnC;AACA,MAAMC,qBAAqB,GAAG,CAAC,2BAAD,EAA8B,mCAA9B,CAA9B;AAEA,MAAMC,YAAY,GAAG,CACnBL,kBADmB,EAEnB,qBAFmB,EAGnB,YAHmB,EAInB,YAJmB,EAKnB,QALmB,EAMnB,WANmB,EAOnB,QAPmB,E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Ac,GAAGA,cAAc,CAACxC,KAAf,CAAqB,CAAC9C,0BAAtB,CAAjB;MACD;IACF,CAZD;;IAcA,IAAI;MACF,MAAMiF,WAAW,CAACW,KAAZ,EAAN;MACA,MAAMX,WAAW,CAACD,IAAZ,EAAN;IACD,CAHD,CAGE,OAAOa,GAAP,EAAY;MACZ,IAAIC,GAAG,GAAI,qCAAoCD,GAAG,CAACE,OAAQ,IAAjD,GACP,wBAAuBL,OAAI,GAAEJ,cAAe,EAD/C;MAEA,KAAK1E,GAAL,CAASoF,aAAT,CAAuBF,GAAvB;IACD;EACF;;AA3JiB;;;eA+JLpF,a"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["PACKAGE_INFO","MODULE_NAME","qualifyActivityName","activityName","packageName","some","name","_","includes","dotPos","indexOf","copyGradleProjectRecursively","sourceBaseDir","targetBaseDir","fs","walkDir","itemPath","isDirectory","relativePath","path","relative","targetPath","resolve","isInGradleBuildDir","sep","mkdirp","copyFile","requireOptions","opts","requiredKeys","missingKeys","difference","keys","isEmpty","Error","updateDependencyLines","originalContent","dependencyPlaceholder","dependencyLines","configurationLines","split","searchRe","RegExp","escapeRegExp","placeholderIndex","findIndex","line","test","placeholderLine","indentLen","length","trimStart","splice","map","repeat","join","getPackageInfo","currentDir","dirname","__filename","isAtFsRoot","manifestPath","exists","manifestPayload","JSON","parse","readFile","ign","getPackageInfoSync","_fs","existsSync","readFileSync"],"sources":["../../lib/utils.js"],"sourcesContent":["import { fs, mkdirp } from 'appium/support';\nimport _ from 'lodash';\nimport path from 'path';\nimport _fs from 'fs';\n\nlet PACKAGE_INFO = null;\nconst MODULE_NAME = 'appium-espresso-driver';\n\n/**\n * https://android.googlesource.com/platform/frameworks/base/+/master/tools/aapt/Resource.cpp#755\n *\n * @param {string} activityName\n * @param {string} packageName\n * @returns {string} The qualified activity name\n */\nfunction qualifyActivityName (activityName, packageName) {\n // if either activity or package name is not set\n // or any of these contain wildcards then there is\n // no point in qualifying the activity name\n if ([activityName, packageName].some((name) => !name || _.includes(name, '*'))) {\n return activityName;\n }\n\n const dotPos = activityName.indexOf('.');\n if (dotPos > 0) {\n return activityName;\n }\n return `${packageName}${dotPos === 0 ? '' : '.'}${activityName}`;\n}\n\n/**\n * Recursively copy all files except build directories contents\n * @param sourceBaseDir {string} directory to copy files from\n * @param targetBaseDir {string} directory to copy files to\n */\nasync function copyGradleProjectRecursively (sourceBaseDir, targetBaseDir) {\n await fs.walkDir(sourceBaseDir, true, async (itemPath, isDirectory) => {\n const relativePath = path.relative(sourceBaseDir, itemPath);\n const targetPath = path.resolve(targetBaseDir, relativePath);\n\n const isInGradleBuildDir = `${path.sep}${itemPath}`.includes(`${path.sep}build${path.sep}`);\n if (isInGradleBuildDir) {\n return false;\n }\n\n if (isDirectory) {\n await mkdirp(targetPath);\n } else {\n await fs.copyFile(itemPath, targetPath);\n }\n return false;\n });\n}\n\nfunction requireOptions (opts, requiredKeys = []) {\n const missingKeys = _.difference(requiredKeys, _.keys(opts));\n if (!_.isEmpty(missingKeys)) {\n throw new Error(`The following options are required: ${missingKeys}`);\n }\n return opts;\n}\n\nfunction updateDependencyLines (originalContent, dependencyPlaceholder, dependencyLines) {\n const configurationLines = originalContent.split('\\n');\n const searchRe = new RegExp(`^\\\\s*//\\\\s*\\\\b${_.escapeRegExp(dependencyPlaceholder)}\\\\b`, 'm');\n const placeholderIndex = configurationLines.findIndex((line) => searchRe.test(line));\n if (placeholderIndex < 0) {\n return originalContent;\n }\n\n const placeholderLine = configurationLines[placeholderIndex];\n const indentLen = placeholderLine.length - _.trimStart(placeholderLine).length;\n configurationLines.splice(placeholderIndex + 1, 0, ...(dependencyLines\n .map((line) => `${' '.repeat(indentLen)}${line}`)));\n return configurationLines.join('\\n');\n}\n\n/**\n * Fetches the module info from package.json\n *\n * @returns {object} The full path to module's package.json and its payload\n * @throws {Error} If package.json cannot be found\n */\nasync function getPackageInfo () {\n if (PACKAGE_INFO) {\n return PACKAGE_INFO;\n }\n\n let currentDir = path.dirname(path.resolve(__filename));\n let isAtFsRoot = false;\n while (!isAtFsRoot) {\n const manifestPath = path.join(currentDir, 'package.json');\n try {\n if (await fs.exists(manifestPath)) {\n const manifestPayload = JSON.parse(await fs.readFile(manifestPath, 'utf8'));\n if (manifestPayload.name === MODULE_NAME) {\n PACKAGE_INFO = {\n manifestPath,\n manifestPayload\n };\n return PACKAGE_INFO;\n }\n }\n } catch (ign) {}\n currentDir = path.dirname(currentDir);\n isAtFsRoot = currentDir.length <= path.dirname(currentDir).length;\n }\n throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);\n}\n\n/**\n * Fetches the module info from package.json synchronously\n *\n * @returns {object} The full path to module's package.json and its payload\n * @throws {Error} If package.json cannot be found\n */\nfunction getPackageInfoSync () {\n if (PACKAGE_INFO) {\n return PACKAGE_INFO;\n }\n\n let currentDir = path.dirname(path.resolve(__filename));\n let isAtFsRoot = false;\n while (!isAtFsRoot) {\n const manifestPath = path.join(currentDir, 'package.json');\n try {\n if (_fs.existsSync(manifestPath)) {\n const manifestPayload = JSON.parse(_fs.readFileSync(manifestPath, 'utf8'));\n if (manifestPayload.name === MODULE_NAME) {\n PACKAGE_INFO = {\n manifestPath,\n manifestPayload\n };\n return PACKAGE_INFO;\n }\n }\n } catch (ign) {}\n currentDir = path.dirname(currentDir);\n isAtFsRoot = currentDir.length <= path.dirname(currentDir).length;\n }\n throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);\n}\n\nexport {\n qualifyActivityName, copyGradleProjectRecursively, requireOptions,\n updateDependencyLines, getPackageInfo, getPackageInfoSync\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,IAAIA,YAAY,GAAG,IAAnB;AACA,MAAMC,WAAW,GAAG,wBAApB;;AASA,SAASC,mBAAT,CAA8BC,YAA9B,EAA4CC,WAA5C,EAAyD;EAIvD,IAAI,CAACD,YAAD,EAAeC,WAAf,EAA4B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