appium-uiautomator2-driver 3.6.0 → 3.7.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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @this {AndroidUiautomator2Driver}
3
+ * @returns {Promise<string>} Base64-encoded content of the clipboard
4
+ * or an empty string if the clipboard is empty.
5
+ */
6
+ export async function getClipboard() {
7
+ return String(
8
+ (await this.adb.getApiLevel()) < 29
9
+ ? await this.uiautomator2.jwproxy.command(
10
+ '/appium/device/get_clipboard',
11
+ 'POST',
12
+ {}
13
+ )
14
+ : await this.settingsApp.getClipboard()
15
+ );
16
+ }
17
+
18
+ /**
19
+ * @this {AndroidUiautomator2Driver}
20
+ * @returns {Promise<string>} Base64-encoded content of the clipboard
21
+ * or an empty string if the clipboard is empty.
22
+ */
23
+ export async function mobileGetClipboard() {
24
+ return await this.getClipboard();
25
+ }
26
+
27
+ /**
28
+ * @this {AndroidUiautomator2Driver}
29
+ * @param {string} content Base64-encoded clipboard payload
30
+ * @param {'plaintext'} [contentType='plaintext'] Only a single
31
+ * content type is supported, which is 'plaintext'
32
+ * @param {string} [label] Optinal label to identify the current
33
+ * clipboard payload
34
+ * @returns {Promise<void>}
35
+ */
36
+ export async function setClipboard(content, contentType, label) {
37
+ await this.uiautomator2.jwproxy.command(
38
+ '/appium/device/set_clipboard',
39
+ 'POST',
40
+ {content, contentType, label}
41
+ );
42
+ }
43
+
44
+ /**
45
+ * @this {AndroidUiautomator2Driver}
46
+ * @param {import('./types').SetClipboardOpts} opts
47
+ * @returns {Promise<void>}
48
+ */
49
+ export async function mobileSetClipboard(opts) {
50
+ await this.setClipboard(opts.content, opts.contentType, opts.label);
51
+ }
52
+
53
+ /**
54
+ * @typedef {import('../driver').AndroidUiautomator2Driver} AndroidUiautomator2Driver
55
+ */
@@ -49,6 +49,9 @@ export function mobileCommandsMapping() {
49
49
  scheduleAction: 'mobileScheduleAction',
50
50
  getActionHistory: 'mobileGetActionHistory',
51
51
  unscheduleAction: 'mobileUnscheduleAction',
52
+
53
+ setClipboard: 'mobileSetClipboard',
54
+ getClipboard: 'mobileGetClipboard',
52
55
  };
53
56
  }
54
57
 
@@ -40,22 +40,6 @@ export async function setOrientation(orientation) {
40
40
  );
41
41
  }
42
42
 
43
- /**
44
- * @this {AndroidUiautomator2Driver}
45
- * @returns {Promise<string>}
46
- */
47
- export async function getClipboard() {
48
- return String(
49
- (await this.adb.getApiLevel()) < 29
50
- ? await this.uiautomator2.jwproxy.command(
51
- '/appium/device/get_clipboard',
52
- 'POST',
53
- {}
54
- )
55
- : await this.settingsApp.getClipboard()
56
- );
57
- }
58
-
59
43
  /**
60
44
  * @this {AndroidUiautomator2Driver}
61
45
  * @returns {Promise<void>}
@@ -471,3 +471,18 @@ export interface ActionResult {
471
471
  export interface ActionArgs {
472
472
  name: string;
473
473
  }
474
+
475
+ export interface SetClipboardOpts {
476
+ /**
477
+ * Base64-encoded clipboard payload
478
+ */
479
+ content: string;
480
+ /**
481
+ * Only a single content type is supported, which is 'plaintext'
482
+ */
483
+ contentType?: 'plaintext';
484
+ /**
485
+ * Optinal label to identify the current clipboard payload
486
+ */
487
+ label?: string;
488
+ }
package/lib/driver.ts CHANGED
@@ -61,6 +61,12 @@ import {
61
61
  import {
62
62
  mobileGetBatteryInfo,
63
63
  } from './commands/battery';
64
+ import {
65
+ getClipboard,
66
+ mobileGetClipboard,
67
+ setClipboard,
68
+ mobileSetClipboard,
69
+ } from './commands/clipboard';
64
70
  import {
65
71
  active,
66
72
  getAttribute,
@@ -111,7 +117,6 @@ import {
111
117
  getPageSource,
112
118
  getOrientation,
113
119
  setOrientation,
114
- getClipboard,
115
120
  openNotifications,
116
121
  suspendChromedriverProxy,
117
122
  mobileGetDeviceInfo,
@@ -1054,11 +1059,15 @@ class AndroidUiautomator2Driver
1054
1059
  getPageSource = getPageSource;
1055
1060
  getOrientation = getOrientation;
1056
1061
  setOrientation = setOrientation;
1057
- getClipboard = getClipboard;
1058
1062
  openNotifications = openNotifications;
1059
1063
  suspendChromedriverProxy = suspendChromedriverProxy as any;
1060
1064
  mobileGetDeviceInfo = mobileGetDeviceInfo;
1061
1065
 
1066
+ getClipboard = getClipboard;
1067
+ mobileGetClipboard = mobileGetClipboard;
1068
+ setClipboard = setClipboard;
1069
+ mobileSetClipboard = mobileSetClipboard;
1070
+
1062
1071
  setUrl = setUrl;
1063
1072
  mobileDeepLink = mobileDeepLink;
1064
1073
  back = back;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appium-uiautomator2-driver",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "appium-uiautomator2-driver",
9
- "version": "3.6.0",
9
+ "version": "3.7.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "appium-adb": "^12.2.0",
@@ -35,23 +35,19 @@
35
35
  "@semantic-release/changelog": "^6.0.1",
36
36
  "@semantic-release/git": "^10.0.1",
37
37
  "@types/bluebird": "^3.5.38",
38
- "@types/chai": "^4.3.5",
39
- "@types/chai-as-promised": "^7.1.5",
40
38
  "@types/lodash": "^4.14.194",
41
39
  "@types/mocha": "^10.0.1",
42
40
  "@types/node": "^20.2.3",
43
41
  "@types/portscanner": "^2.1.1",
44
42
  "@types/semver": "^7.5.0",
45
- "@types/sinon": "^17.0.0",
46
- "@types/sinon-chai": "^3.2.9",
47
43
  "@types/source-map-support": "^0.x",
48
44
  "@types/teen_process": "^2.0.0",
49
45
  "@types/ws": "^8.5.4",
50
46
  "@xmldom/xmldom": "^0.x",
51
47
  "android-apidemos": "^4.1.1",
52
48
  "appium": "^2.0.0-rc.3",
53
- "chai": "^4.1.2",
54
- "chai-as-promised": "^7.1.1",
49
+ "chai": "^5.1.1",
50
+ "chai-as-promised": "^8.0.0",
55
51
  "conventional-changelog-conventionalcommits": "^8.0.0",
56
52
  "fancy-log": "^2.0.0",
57
53
  "mocha": "^10.0.0",
@@ -60,7 +56,6 @@
60
56
  "semantic-release": "^24.0.0",
61
57
  "sharp": "^0.x",
62
58
  "sinon": "^18.0.0",
63
- "sinon-chai": "^3.7.0",
64
59
  "ts-node": "^10.9.1",
65
60
  "typescript": "^5.4.2",
66
61
  "unzipper": "^0.x",
@@ -806,9 +801,9 @@
806
801
  }
807
802
  },
808
803
  "node_modules/@types/node": {
809
- "version": "20.14.8",
810
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz",
811
- "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==",
804
+ "version": "20.14.9",
805
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz",
806
+ "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==",
812
807
  "dependencies": {
813
808
  "undici-types": "~5.26.4"
814
809
  }
@@ -1077,11 +1072,11 @@
1077
1072
  }
1078
1073
  },
1079
1074
  "node_modules/appium-android-driver": {
1080
- "version": "9.7.0",
1081
- "resolved": "https://registry.npmjs.org/appium-android-driver/-/appium-android-driver-9.7.0.tgz",
1082
- "integrity": "sha512-0XWMOuuA8uzMcHturqYwfECnY6imfPzXuPxs75/XfUuyDCkVE7zHoAQaYJes3Q3A6tE9MEMTvmY3GKyjJR6koQ==",
1075
+ "version": "9.7.2",
1076
+ "resolved": "https://registry.npmjs.org/appium-android-driver/-/appium-android-driver-9.7.2.tgz",
1077
+ "integrity": "sha512-AxguUmVx3YqFOMBjIeWqA8mAiRMk9/pJXjlS/SQc8dezS4v8YSvuNP1fjihrndq70HDrQJ6ciW46nGug1i3BWw==",
1083
1078
  "dependencies": {
1084
- "@appium/support": "^4.2.0",
1079
+ "@appium/support": "^5.0.3",
1085
1080
  "@colors/colors": "^1.6.0",
1086
1081
  "appium-adb": "^12.3.0",
1087
1082
  "appium-chromedriver": "^5.5.1",
@@ -1108,133 +1103,10 @@
1108
1103
  "appium": "^2.0.0"
1109
1104
  }
1110
1105
  },
1111
- "node_modules/appium-android-driver/node_modules/@appium/schema": {
1112
- "version": "0.5.0",
1113
- "resolved": "https://registry.npmjs.org/@appium/schema/-/schema-0.5.0.tgz",
1114
- "integrity": "sha512-HFed9HtFU6+kLdVyp/xpS/Wfcge8PuMS37LJVShviT6OuzHOYvNFx1/y8+KMa/l0Npvll5eafdfHmUsWlRnUAA==",
1115
- "dependencies": {
1116
- "@types/json-schema": "7.0.15",
1117
- "json-schema": "0.4.0",
1118
- "source-map-support": "0.5.21"
1119
- },
1120
- "engines": {
1121
- "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
1122
- "npm": ">=8"
1123
- }
1124
- },
1125
- "node_modules/appium-android-driver/node_modules/@appium/support": {
1126
- "version": "4.5.0",
1127
- "resolved": "https://registry.npmjs.org/@appium/support/-/support-4.5.0.tgz",
1128
- "integrity": "sha512-9pr8sjnvQud3gBaF/RGj1FdySPjcOuDuKE5w4rfYht/HHlnC3GkfNtQG1FH4rqAIbkOk72HoFr4eaQrQV/cc3g==",
1129
- "dependencies": {
1130
- "@appium/logger": "^1.3.0",
1131
- "@appium/tsconfig": "^0.3.3",
1132
- "@appium/types": "^0.19.2",
1133
- "@colors/colors": "1.6.0",
1134
- "@types/archiver": "6.0.2",
1135
- "@types/base64-stream": "1.0.5",
1136
- "@types/find-root": "1.1.4",
1137
- "@types/jsftp": "2.1.5",
1138
- "@types/klaw": "3.0.6",
1139
- "@types/lockfile": "1.0.4",
1140
- "@types/mv": "2.1.4",
1141
- "@types/ncp": "2.0.8",
1142
- "@types/pluralize": "0.0.33",
1143
- "@types/semver": "7.5.8",
1144
- "@types/shell-quote": "1.7.5",
1145
- "@types/supports-color": "8.1.3",
1146
- "@types/teen_process": "2.0.4",
1147
- "@types/uuid": "9.0.8",
1148
- "@types/which": "3.0.4",
1149
- "archiver": "7.0.1",
1150
- "axios": "1.7.2",
1151
- "base64-stream": "1.0.0",
1152
- "bluebird": "3.7.2",
1153
- "bplist-creator": "0.1.1",
1154
- "bplist-parser": "0.3.2",
1155
- "form-data": "4.0.0",
1156
- "get-stream": "6.0.1",
1157
- "glob": "10.4.1",
1158
- "jsftp": "2.1.3",
1159
- "klaw": "4.1.0",
1160
- "lockfile": "1.0.4",
1161
- "lodash": "4.17.21",
1162
- "log-symbols": "4.1.0",
1163
- "moment": "2.30.1",
1164
- "mv": "2.1.1",
1165
- "ncp": "2.0.0",
1166
- "opencv-bindings": "4.5.5",
1167
- "pkg-dir": "5.0.0",
1168
- "plist": "3.1.0",
1169
- "pluralize": "8.0.0",
1170
- "read-pkg": "5.2.0",
1171
- "resolve-from": "5.0.0",
1172
- "sanitize-filename": "1.6.3",
1173
- "semver": "7.6.2",
1174
- "shell-quote": "1.8.1",
1175
- "source-map-support": "0.5.21",
1176
- "supports-color": "8.1.1",
1177
- "teen_process": "2.1.4",
1178
- "type-fest": "4.19.0",
1179
- "uuid": "9.0.1",
1180
- "which": "4.0.0",
1181
- "yauzl": "3.1.3"
1182
- },
1183
- "engines": {
1184
- "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
1185
- "npm": ">=8"
1186
- },
1187
- "optionalDependencies": {
1188
- "sharp": "0.33.4"
1189
- }
1190
- },
1191
- "node_modules/appium-android-driver/node_modules/@appium/types": {
1192
- "version": "0.19.2",
1193
- "resolved": "https://registry.npmjs.org/@appium/types/-/types-0.19.2.tgz",
1194
- "integrity": "sha512-u4oHR8TaFK3uyptgOT26/u3zQU5N6vh652OHIpRDJ78EDWgCWXLfIA6YdF8tA8YMrvZHhRpX9om04+9l8wSXyA==",
1195
- "dependencies": {
1196
- "@appium/logger": "^1.3.0",
1197
- "@appium/schema": "^0.5.0",
1198
- "@appium/tsconfig": "^0.3.3",
1199
- "@types/express": "4.17.21",
1200
- "@types/ws": "8.5.10",
1201
- "type-fest": "4.19.0"
1202
- },
1203
- "engines": {
1204
- "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
1205
- "npm": ">=8"
1206
- }
1207
- },
1208
- "node_modules/appium-android-driver/node_modules/teen_process": {
1209
- "version": "2.1.4",
1210
- "resolved": "https://registry.npmjs.org/teen_process/-/teen_process-2.1.4.tgz",
1211
- "integrity": "sha512-TEaxCYk/aCBsNBCZmgUNXqtCWq8RX94nGoyYYu7YiNR+RnmawMFshTkYe1SFhiNCX6FsYb6wL/irs6NhvfoF5g==",
1212
- "dependencies": {
1213
- "bluebird": "^3.7.2",
1214
- "lodash": "^4.17.21",
1215
- "shell-quote": "^1.8.1",
1216
- "source-map-support": "^0.x"
1217
- },
1218
- "engines": {
1219
- "node": "^16.13.0 || >=18.0.0",
1220
- "npm": ">=8"
1221
- }
1222
- },
1223
- "node_modules/appium-android-driver/node_modules/type-fest": {
1224
- "version": "4.19.0",
1225
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.19.0.tgz",
1226
- "integrity": "sha512-CN2l+hWACRiejlnr68vY0/7734Kzu+9+TOslUXbSCQ1ruY9XIHDBSceVXCcHm/oXrdzhtLMMdJEKfemf1yXiZQ==",
1227
- "engines": {
1228
- "node": ">=16"
1229
- },
1230
- "funding": {
1231
- "url": "https://github.com/sponsors/sindresorhus"
1232
- }
1233
- },
1234
1106
  "node_modules/appium-chromedriver": {
1235
- "version": "5.6.61",
1236
- "resolved": "https://registry.npmjs.org/appium-chromedriver/-/appium-chromedriver-5.6.61.tgz",
1237
- "integrity": "sha512-PO2HioadxOE+yijz+YgPbWxAbPJn0H0mW1tTvpWz45x9kTWMgXY5lXAv9jSZsSF2iTx8DOxInUltEBr9dPIjLw==",
1107
+ "version": "5.6.62",
1108
+ "resolved": "https://registry.npmjs.org/appium-chromedriver/-/appium-chromedriver-5.6.62.tgz",
1109
+ "integrity": "sha512-kl5IVK1bRpihAHW2O3DBF0xuWzorraRh1q0/+a/Tlfd6KFCB0mF1HBDW/CnT3g8asZvQaftu3o6nKlKXaYeuHQ==",
1238
1110
  "hasInstallScript": true,
1239
1111
  "dependencies": {
1240
1112
  "@appium/base-driver": "^9.1.0",
@@ -1381,9 +1253,9 @@
1381
1253
  }
1382
1254
  },
1383
1255
  "node_modules/appium-uiautomator2-server": {
1384
- "version": "7.0.14",
1385
- "resolved": "https://registry.npmjs.org/appium-uiautomator2-server/-/appium-uiautomator2-server-7.0.14.tgz",
1386
- "integrity": "sha512-EfR+ifutelJBBeGYMANIhuX9ClXqsaXoQR0fssJotnTay3htvJuMvELUVHrMT5aQnzEG70Xfz2W67cgjcqGFVQ==",
1256
+ "version": "7.0.15",
1257
+ "resolved": "https://registry.npmjs.org/appium-uiautomator2-server/-/appium-uiautomator2-server-7.0.15.tgz",
1258
+ "integrity": "sha512-exTM7AAH7wL9flaLrHmP7zplgUPAMj3dfpfGpa5wWcZbpUVUqKMxxZLi1ZY2stmCIPTGoYWuAF4h2T9f1Qe2DQ==",
1387
1259
  "engines": {
1388
1260
  "node": ">=14",
1389
1261
  "npm": ">=8"
@@ -3184,9 +3056,9 @@
3184
3056
  "optional": true
3185
3057
  },
3186
3058
  "node_modules/minimatch": {
3187
- "version": "9.0.4",
3188
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz",
3189
- "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==",
3059
+ "version": "9.0.5",
3060
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
3061
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
3190
3062
  "dependencies": {
3191
3063
  "brace-expansion": "^2.0.1"
3192
3064
  },
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "automated testing",
8
8
  "android"
9
9
  ],
10
- "version": "3.6.0",
10
+ "version": "3.7.0",
11
11
  "bugs": {
12
12
  "url": "https://github.com/appium/appium-uiautomator2-driver/issues"
13
13
  },
@@ -82,23 +82,19 @@
82
82
  "@semantic-release/changelog": "^6.0.1",
83
83
  "@semantic-release/git": "^10.0.1",
84
84
  "@types/bluebird": "^3.5.38",
85
- "@types/chai": "^4.3.5",
86
- "@types/chai-as-promised": "^7.1.5",
87
85
  "@types/lodash": "^4.14.194",
88
86
  "@types/mocha": "^10.0.1",
89
87
  "@types/node": "^20.2.3",
90
88
  "@types/portscanner": "^2.1.1",
91
89
  "@types/semver": "^7.5.0",
92
- "@types/sinon": "^17.0.0",
93
- "@types/sinon-chai": "^3.2.9",
94
90
  "@types/source-map-support": "^0.x",
95
91
  "@types/teen_process": "^2.0.0",
96
92
  "@types/ws": "^8.5.4",
97
93
  "@xmldom/xmldom": "^0.x",
98
94
  "android-apidemos": "^4.1.1",
99
95
  "appium": "^2.0.0-rc.3",
100
- "chai": "^4.1.2",
101
- "chai-as-promised": "^7.1.1",
96
+ "chai": "^5.1.1",
97
+ "chai-as-promised": "^8.0.0",
102
98
  "conventional-changelog-conventionalcommits": "^8.0.0",
103
99
  "fancy-log": "^2.0.0",
104
100
  "mocha": "^10.0.0",
@@ -107,7 +103,6 @@
107
103
  "semantic-release": "^24.0.0",
108
104
  "sharp": "^0.x",
109
105
  "sinon": "^18.0.0",
110
- "sinon-chai": "^3.7.0",
111
106
  "ts-node": "^10.9.1",
112
107
  "typescript": "^5.4.2",
113
108
  "unzipper": "^0.x",