appium-uiautomator2-driver 6.7.2 → 6.7.4
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/CHANGELOG.md +12 -0
- package/build/lib/commands/find.js +2 -5
- package/build/lib/commands/find.js.map +1 -1
- package/build/lib/css-converter.d.ts +9 -42
- package/build/lib/css-converter.d.ts.map +1 -1
- package/build/lib/css-converter.js +73 -148
- package/build/lib/css-converter.js.map +1 -1
- package/build/lib/extensions.d.ts +2 -2
- package/build/lib/extensions.d.ts.map +1 -1
- package/build/lib/extensions.js +2 -4
- package/build/lib/extensions.js.map +1 -1
- package/build/lib/helpers.d.ts +3 -12
- package/build/lib/helpers.d.ts.map +1 -1
- package/build/lib/helpers.js +1 -11
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/logger.d.ts +1 -2
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +2 -2
- package/build/lib/logger.js.map +1 -1
- package/build/lib/uiautomator2.d.ts +1 -1
- package/build/lib/uiautomator2.d.ts.map +1 -1
- package/build/lib/uiautomator2.js +0 -1
- package/build/lib/uiautomator2.js.map +1 -1
- package/build/test/unit/css-converter-specs.js +3 -6
- package/build/test/unit/css-converter-specs.js.map +1 -1
- package/build/test/unit/uiautomator2-specs.js +4 -4
- package/build/test/unit/uiautomator2-specs.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/commands/find.js +1 -1
- package/lib/css-converter.ts +283 -0
- package/lib/extensions.ts +3 -0
- package/lib/helpers.ts +31 -0
- package/lib/logger.ts +4 -0
- package/lib/uiautomator2.ts +0 -1
- package/npm-shrinkwrap.json +85 -27
- package/package.json +2 -2
- package/lib/css-converter.js +0 -329
- package/lib/extensions.js +0 -4
- package/lib/helpers.js +0 -37
- package/lib/logger.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [6.7.4](https://github.com/appium/appium-uiautomator2-driver/compare/v6.7.3...v6.7.4) (2025-12-22)
|
|
2
|
+
|
|
3
|
+
### Miscellaneous Chores
|
|
4
|
+
|
|
5
|
+
* Migrate various .js modules to typescript (part 1) ([#968](https://github.com/appium/appium-uiautomator2-driver/issues/968)) ([999aa17](https://github.com/appium/appium-uiautomator2-driver/commit/999aa17f09fc246c99d332583f6d55bd47df5e57))
|
|
6
|
+
|
|
7
|
+
## [6.7.3](https://github.com/appium/appium-uiautomator2-driver/compare/v6.7.2...v6.7.3) (2025-12-18)
|
|
8
|
+
|
|
9
|
+
### Miscellaneous Chores
|
|
10
|
+
|
|
11
|
+
* **deps:** bump asyncbox from 3.0.0 to 4.0.1 ([#967](https://github.com/appium/appium-uiautomator2-driver/issues/967)) ([38d3274](https://github.com/appium/appium-uiautomator2-driver/commit/38d3274969194660bbfb5fef5245f9aef0ca49c9))
|
|
12
|
+
|
|
1
13
|
## [6.7.2](https://github.com/appium/appium-uiautomator2-driver/compare/v6.7.1...v6.7.2) (2025-12-17)
|
|
2
14
|
|
|
3
15
|
### Miscellaneous Chores
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.doFindElementOrEls = doFindElementOrEls;
|
|
7
|
-
const css_converter_1 =
|
|
4
|
+
const css_converter_1 = require("../css-converter");
|
|
8
5
|
// we override the xpath search for this first-visible-child selector, which
|
|
9
6
|
// looks like /*[@firstVisible="true"]
|
|
10
7
|
const MAGIC_FIRST_VIS_CHILD_SEL = /\/\*\[@firstVisible ?= ?('|")true\1\]/;
|
|
@@ -30,7 +27,7 @@ async function doFindElementOrEls(params) {
|
|
|
30
27
|
}
|
|
31
28
|
if (params.strategy === 'css selector') {
|
|
32
29
|
params.strategy = '-android uiautomator';
|
|
33
|
-
params.selector = new css_converter_1.
|
|
30
|
+
params.selector = new css_converter_1.CssConverter(params.selector, this.opts.appPackage).toUiAutomatorSelector();
|
|
34
31
|
}
|
|
35
32
|
return /** @type {Element|Element[]} */ (await uiautomator2.jwproxy.command(`/element${params.multiple ? 's' : ''}`, 'POST', params));
|
|
36
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../lib/commands/find.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../lib/commands/find.js"],"names":[],"mappings":";;AAiBA,gDAwBC;AAzCD,oDAA8C;AAE9C,4EAA4E;AAC5E,sCAAsC;AACtC,MAAM,yBAAyB,GAAG,uCAAuC,CAAC;AAE1E,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AACrE,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAEhE;;;;;;;GAOG;AACI,KAAK,UAAU,kBAAkB,CAAC,MAAM;IAC7C,MAAM,YAAY,GAAG,2DAA2D,CAAC,CAC/E,IAAI,CAAC,YAAY,CAClB,CAAC;IACF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnF,IAAI,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,OAAO,sBAAsB,CAAC,CAC5B,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,SAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5F,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9E,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;QACvC,MAAM,CAAC,QAAQ,GAAG,sBAAsB,CAAC;QACzC,MAAM,CAAC,QAAQ,GAAG,IAAI,4BAAY,CAChC,MAAM,CAAC,QAAQ,EACf,IAAI,CAAC,IAAI,CAAC,UAAU,CACrB,CAAC,qBAAqB,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,gCAAgC,CAAC,CACtC,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAC5F,CAAC;AACJ,CAAC;AAED;;;GAGG"}
|
|
@@ -1,45 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
selector:
|
|
5
|
-
pkg: any;
|
|
6
|
-
/**
|
|
7
|
-
* Add `<pkgName>:id/` prefix to beginning of string if it's not there already
|
|
8
|
-
*
|
|
9
|
-
* @param {string} locator The initial locator
|
|
10
|
-
* @returns {string} String with `<pkgName>:id/` prepended (if it wasn't already)
|
|
11
|
-
*/
|
|
12
|
-
formatIdLocator(locator: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Convert a CSS attribute into a UiSelector method call
|
|
15
|
-
*
|
|
16
|
-
* @param {import('css-selector-parser').AstAttribute} cssAttr CSS attribute object
|
|
17
|
-
* @returns {string} CSS attribute parsed as UiSelector
|
|
18
|
-
*/
|
|
19
|
-
parseAttr(cssAttr: import("css-selector-parser").AstAttribute): string;
|
|
20
|
-
/**
|
|
21
|
-
* Convert a CSS pseudo class to a UiSelector
|
|
22
|
-
*
|
|
23
|
-
* @param {import('css-selector-parser').AstPseudoClass} cssPseudo CSS Pseudo class
|
|
24
|
-
* @returns {string|null|undefined} Pseudo selector parsed as UiSelector
|
|
25
|
-
*/
|
|
26
|
-
parsePseudo(cssPseudo: import("css-selector-parser").AstPseudoClass): string | null | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Convert a CSS rule to a UiSelector
|
|
29
|
-
* @param {import('css-selector-parser').AstRule} cssRule CSS rule definition
|
|
30
|
-
*/
|
|
31
|
-
parseCssRule(cssRule: import("css-selector-parser").AstRule): string;
|
|
32
|
-
/**
|
|
33
|
-
* Convert CSS object to UiAutomator2 selector
|
|
34
|
-
* @param {import('css-selector-parser').AstSelector} css CSS object
|
|
35
|
-
* @returns {string} The CSS object parsed as a UiSelector
|
|
36
|
-
*/
|
|
37
|
-
parseCssObject(css: import("css-selector-parser").AstSelector): string;
|
|
38
|
-
/**
|
|
39
|
-
* Convert a CSS selector to a UiAutomator2 selector
|
|
40
|
-
*
|
|
41
|
-
* @returns {string} The CSS selector converted to a UiSelector
|
|
42
|
-
*/
|
|
1
|
+
export declare class CssConverter {
|
|
2
|
+
private readonly selector;
|
|
3
|
+
private readonly pkg?;
|
|
4
|
+
constructor(selector: string, pkg?: string | null | undefined);
|
|
43
5
|
toUiAutomatorSelector(): string;
|
|
6
|
+
private formatIdLocator;
|
|
7
|
+
private parseAttr;
|
|
8
|
+
private parsePseudo;
|
|
9
|
+
private parseCssRule;
|
|
10
|
+
private parseCssObject;
|
|
44
11
|
}
|
|
45
12
|
//# sourceMappingURL=css-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-converter.d.ts","sourceRoot":"","sources":["../../lib/css-converter.
|
|
1
|
+
{"version":3,"file":"css-converter.d.ts","sourceRoot":"","sources":["../../lib/css-converter.ts"],"names":[],"mappings":"AAwHA,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;gBADJ,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,YAAA;IAGtC,qBAAqB,IAAI,MAAM;IAoB/B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,SAAS;IAqDjB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,YAAY;IAqDpB,OAAO,CAAC,cAAc;CAOvB"}
|
|
@@ -3,160 +3,137 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CssConverter = void 0;
|
|
6
7
|
const css_selector_parser_1 = require("css-selector-parser");
|
|
7
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
9
|
const driver_1 = require("appium/driver");
|
|
9
|
-
const logger_1 =
|
|
10
|
+
const logger_1 = require("./logger");
|
|
10
11
|
const parseCssSelector = (0, css_selector_parser_1.createParser)({
|
|
11
12
|
syntax: {
|
|
12
13
|
pseudoClasses: {
|
|
13
14
|
unknown: 'accept',
|
|
14
15
|
definitions: {
|
|
15
16
|
Selector: ['has'],
|
|
16
|
-
}
|
|
17
|
+
},
|
|
17
18
|
},
|
|
18
19
|
combinators: ['>', '+', '~'],
|
|
19
20
|
attributes: {
|
|
20
|
-
operators: ['^=', '$=', '*=', '~=', '=']
|
|
21
|
+
operators: ['^=', '$=', '*=', '~=', '='],
|
|
21
22
|
},
|
|
22
23
|
ids: true,
|
|
23
24
|
classNames: true,
|
|
24
25
|
tag: {
|
|
25
|
-
wildcard: true
|
|
26
|
+
wildcard: true,
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
|
-
substitutes: true
|
|
29
|
+
substitutes: true,
|
|
29
30
|
});
|
|
30
31
|
const RESOURCE_ID = 'resource-id';
|
|
31
32
|
const ID_LOCATOR_PATTERN = /^[a-zA-Z_][a-zA-Z0-9._]*:id\/[\S]+$/;
|
|
32
33
|
const BOOLEAN_ATTRS = [
|
|
33
|
-
'checkable',
|
|
34
|
-
'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'
|
|
34
|
+
'checkable',
|
|
35
|
+
'checked',
|
|
36
|
+
'clickable',
|
|
37
|
+
'enabled',
|
|
38
|
+
'focusable',
|
|
39
|
+
'focused',
|
|
40
|
+
'long-clickable',
|
|
41
|
+
'scrollable',
|
|
42
|
+
'selected',
|
|
41
43
|
];
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...STR_ATTRS,
|
|
46
|
-
];
|
|
47
|
-
/** @type {[string, string[]][]} */
|
|
44
|
+
const NUMERIC_ATTRS = ['index', 'instance'];
|
|
45
|
+
const STR_ATTRS = ['description', RESOURCE_ID, 'text', 'class-name', 'package-name'];
|
|
46
|
+
const ALL_ATTRS = [...BOOLEAN_ATTRS, ...NUMERIC_ATTRS, ...STR_ATTRS];
|
|
48
47
|
const ATTRIBUTE_ALIASES = [
|
|
49
48
|
[RESOURCE_ID, ['id']],
|
|
50
|
-
[
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
[
|
|
50
|
+
'description',
|
|
51
|
+
['content-description', 'content-desc', 'desc', 'accessibility-id'],
|
|
52
|
+
],
|
|
54
53
|
['index', ['nth-child']],
|
|
55
54
|
];
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
55
|
+
const isAstAttribute = (item) => item.type === 'Attribute';
|
|
56
|
+
const isAstPseudoClass = (item) => item.type === 'PseudoClass';
|
|
57
|
+
const isAstClassName = (item) => item.type === 'ClassName';
|
|
58
|
+
const isAstTagName = (item) => item.type === 'TagName';
|
|
59
|
+
const isAstId = (item) => item.type === 'Id';
|
|
62
60
|
function toSnakeCase(str) {
|
|
63
61
|
if (!str) {
|
|
64
62
|
return '';
|
|
65
63
|
}
|
|
66
|
-
const tokens = str
|
|
64
|
+
const tokens = str
|
|
65
|
+
.split('-')
|
|
66
|
+
.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase());
|
|
67
67
|
const out = tokens.join('');
|
|
68
68
|
return out.charAt(0).toLowerCase() + out.slice(1);
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Get the boolean from a CSS object. If empty, return true. If not true/false/empty, throw exception
|
|
72
|
-
*
|
|
73
|
-
* @param {import('css-selector-parser').AstAttribute|import('css-selector-parser').AstPseudoClass} css A
|
|
74
|
-
* CSS object that has 'name' and 'value'
|
|
75
|
-
* @returns {string} Either 'true' or 'false'. If value is empty, return 'true'
|
|
76
|
-
*/
|
|
77
70
|
function requireBoolean(css) {
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
71
|
+
const rawValue = css.value?.value ?? css.argument?.value;
|
|
72
|
+
const value = lodash_1.default.toLower(rawValue ?? 'true');
|
|
73
|
+
if (value === 'true') {
|
|
74
|
+
return 'true';
|
|
75
|
+
}
|
|
76
|
+
if (value === 'false') {
|
|
77
|
+
return 'false';
|
|
82
78
|
}
|
|
83
|
-
// @ts-ignore The attribute should exist
|
|
84
79
|
throw new Error(`'${css.name}' must be true, false or empty. Found '${css.value}'`);
|
|
85
80
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Get the canonical form of a CSS attribute name
|
|
88
|
-
*
|
|
89
|
-
* Converts to lowercase and if an attribute name is an alias for something else, return
|
|
90
|
-
* what it is an alias for
|
|
91
|
-
*
|
|
92
|
-
* @param {import('css-selector-parser').AstAttribute|import('css-selector-parser').AstPseudoClass} cssEntity CSS object
|
|
93
|
-
* @returns {string} The canonical attribute name
|
|
94
|
-
*/
|
|
95
81
|
function requireEntityName(cssEntity) {
|
|
96
82
|
const attrName = cssEntity.name.toLowerCase();
|
|
97
|
-
// Check if it's supported and if it is, return it
|
|
98
83
|
if (ALL_ATTRS.includes(attrName)) {
|
|
99
|
-
return attrName
|
|
84
|
+
return attrName;
|
|
100
85
|
}
|
|
101
|
-
// If attrName is an alias for something else, return that
|
|
102
86
|
for (const [officialAttr, aliasAttrs] of ATTRIBUTE_ALIASES) {
|
|
103
87
|
if (aliasAttrs.includes(attrName)) {
|
|
104
88
|
return officialAttr;
|
|
105
89
|
}
|
|
106
90
|
}
|
|
107
|
-
throw new Error(`'${attrName}' is not a valid attribute. `
|
|
108
|
-
`Supported attributes are '${ALL_ATTRS.join(', ')}'`);
|
|
91
|
+
throw new Error(`'${attrName}' is not a valid attribute. Supported attributes are '${ALL_ATTRS.join(', ')}'`);
|
|
109
92
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Get a regex that matches a whole word. For the ~= CSS attribute selector.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} word
|
|
114
|
-
* @returns {string} A regex "word" matcher
|
|
115
|
-
*/
|
|
116
93
|
function getWordMatcherRegex(word) {
|
|
117
94
|
return `\\b(\\w*${lodash_1.default.escapeRegExp(word)}\\w*)\\b`;
|
|
118
95
|
}
|
|
119
96
|
class CssConverter {
|
|
97
|
+
selector;
|
|
98
|
+
pkg;
|
|
120
99
|
constructor(selector, pkg) {
|
|
121
100
|
this.selector = selector;
|
|
122
101
|
this.pkg = pkg;
|
|
123
102
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
103
|
+
toUiAutomatorSelector() {
|
|
104
|
+
let cssObj;
|
|
105
|
+
try {
|
|
106
|
+
cssObj = parseCssSelector(this.selector);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
logger_1.log.debug(e.stack);
|
|
110
|
+
throw new driver_1.errors.InvalidSelectorError(`Invalid CSS selector '${this.selector}'. Reason: '${e.message}'`);
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
return this.parseCssObject(cssObj);
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
logger_1.log.debug(e.stack);
|
|
117
|
+
throw new driver_1.errors.InvalidSelectorError(`Unsupported CSS selector '${this.selector}'. Reason: '${e.message}'`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
130
120
|
formatIdLocator(locator) {
|
|
131
|
-
return ID_LOCATOR_PATTERN.test(locator)
|
|
132
|
-
? locator
|
|
133
|
-
: `${this.pkg || 'android'}:id/${locator}`;
|
|
121
|
+
return ID_LOCATOR_PATTERN.test(locator) ? locator : `${this.pkg || 'android'}:id/${locator}`;
|
|
134
122
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Convert a CSS attribute into a UiSelector method call
|
|
137
|
-
*
|
|
138
|
-
* @param {import('css-selector-parser').AstAttribute} cssAttr CSS attribute object
|
|
139
|
-
* @returns {string} CSS attribute parsed as UiSelector
|
|
140
|
-
*/
|
|
141
123
|
parseAttr(cssAttr) {
|
|
142
|
-
|
|
143
|
-
const attrValue =
|
|
124
|
+
const attrValueNode = cssAttr.value;
|
|
125
|
+
const attrValue = attrValueNode?.value;
|
|
144
126
|
if (!lodash_1.default.isString(attrValue) && !lodash_1.default.isEmpty(attrValue)) {
|
|
145
|
-
throw new Error(`'${cssAttr.name}=${attrValue}' is an invalid attribute. `
|
|
146
|
-
`Only 'string' and empty attribute types are supported. Found '${attrValue}'`);
|
|
127
|
+
throw new Error(`'${cssAttr.name}=${attrValue}' is an invalid attribute. Only 'string' and empty attribute types are supported. Found '${attrValue}'`);
|
|
147
128
|
}
|
|
148
129
|
const attrName = requireEntityName(cssAttr);
|
|
149
130
|
const methodName = toSnakeCase(attrName);
|
|
150
|
-
// Validate that it's a supported attribute
|
|
151
131
|
if (!STR_ATTRS.includes(attrName) && !BOOLEAN_ATTRS.includes(attrName)) {
|
|
152
|
-
throw new Error(`'${attrName}' is not supported. Supported attributes are `
|
|
153
|
-
`'${[...STR_ATTRS, ...BOOLEAN_ATTRS].join(', ')}'`);
|
|
132
|
+
throw new Error(`'${attrName}' is not supported. Supported attributes are '${[...STR_ATTRS, ...BOOLEAN_ATTRS].join(', ')}'`);
|
|
154
133
|
}
|
|
155
|
-
// Parse boolean, if it's a boolean attribute
|
|
156
134
|
if (BOOLEAN_ATTRS.includes(attrName)) {
|
|
157
135
|
return `.${methodName}(${requireBoolean(cssAttr)})`;
|
|
158
136
|
}
|
|
159
|
-
// Otherwise parse as string
|
|
160
137
|
let value = attrValue || '';
|
|
161
138
|
if (attrName === RESOURCE_ID) {
|
|
162
139
|
value = this.formatIdLocator(value);
|
|
@@ -182,23 +159,13 @@ class CssConverter {
|
|
|
182
159
|
case '~=':
|
|
183
160
|
return `.${methodName}Matches("${getWordMatcherRegex(value)}")`;
|
|
184
161
|
default:
|
|
185
|
-
|
|
186
|
-
throw new Error(`Unsupported CSS attribute operator '${cssAttr.operator}'. ` +
|
|
187
|
-
` '=', '*=', '^=', '$=' and '~=' are supported.`);
|
|
162
|
+
throw new Error(`Unsupported CSS attribute operator '${cssAttr.operator}'. '=', '*=', '^=', '$=' and '~=' are supported.`);
|
|
188
163
|
}
|
|
189
164
|
}
|
|
190
|
-
/**
|
|
191
|
-
* Convert a CSS pseudo class to a UiSelector
|
|
192
|
-
*
|
|
193
|
-
* @param {import('css-selector-parser').AstPseudoClass} cssPseudo CSS Pseudo class
|
|
194
|
-
* @returns {string|null|undefined} Pseudo selector parsed as UiSelector
|
|
195
|
-
*/
|
|
196
165
|
parsePseudo(cssPseudo) {
|
|
197
|
-
// @ts-ignore The attribute should exist
|
|
198
166
|
const argValue = cssPseudo.argument?.value;
|
|
199
167
|
if (!lodash_1.default.isString(argValue) && !lodash_1.default.isEmpty(argValue)) {
|
|
200
|
-
throw new Error(`'${cssPseudo.name}=${argValue}'.
|
|
201
|
-
`Unsupported css pseudo class value: '${argValue}'. Only 'string' type or empty is supported.`);
|
|
168
|
+
throw new Error(`'${cssPseudo.name}=${argValue}'. Unsupported css pseudo class value: '${argValue}'. Only 'string' type or empty is supported.`);
|
|
202
169
|
}
|
|
203
170
|
const pseudoName = requireEntityName(cssPseudo);
|
|
204
171
|
if (BOOLEAN_ATTRS.includes(pseudoName)) {
|
|
@@ -208,24 +175,15 @@ class CssConverter {
|
|
|
208
175
|
return `.${pseudoName}(${argValue})`;
|
|
209
176
|
}
|
|
210
177
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Convert a CSS rule to a UiSelector
|
|
213
|
-
* @param {import('css-selector-parser').AstRule} cssRule CSS rule definition
|
|
214
|
-
*/
|
|
215
178
|
parseCssRule(cssRule) {
|
|
216
179
|
if (cssRule.combinator && ![' ', '>'].includes(cssRule.combinator)) {
|
|
217
|
-
throw new Error(`'${cssRule.combinator}' is not a supported combinator.
|
|
218
|
-
`Only child combinator (>) and descendant combinator are supported.`);
|
|
180
|
+
throw new Error(`'${cssRule.combinator}' is not a supported combinator. Only child combinator (>) and descendant combinator are supported.`);
|
|
219
181
|
}
|
|
220
|
-
/** @type {string[]} */
|
|
221
182
|
const uiAutomatorSelector = ['new UiSelector()'];
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const astClassNames = cssRule.items.filter(({ type }) => type === 'ClassName');
|
|
183
|
+
const items = cssRule.items ?? [];
|
|
184
|
+
const astClassNames = items.filter(isAstClassName);
|
|
225
185
|
const classNames = astClassNames.map(({ name }) => name);
|
|
226
|
-
|
|
227
|
-
// @ts-ignore This should work
|
|
228
|
-
const astTag = cssRule.items.find(({ type }) => type === 'TagName');
|
|
186
|
+
const astTag = items.find(isAstTagName);
|
|
229
187
|
const tagName = astTag?.name;
|
|
230
188
|
if (tagName && tagName !== '*') {
|
|
231
189
|
const androidClass = [tagName];
|
|
@@ -242,22 +200,16 @@ class CssConverter {
|
|
|
242
200
|
else if (classNames.length) {
|
|
243
201
|
uiAutomatorSelector.push(`.classNameMatches("${classNames.join('\\.')}")`);
|
|
244
202
|
}
|
|
245
|
-
|
|
246
|
-
// @ts-ignore This should work
|
|
247
|
-
const astIds = cssRule.items.filter(({ type }) => type === 'Id');
|
|
203
|
+
const astIds = items.filter(isAstId);
|
|
248
204
|
const ids = astIds.map(({ name }) => name);
|
|
249
205
|
if (ids.length) {
|
|
250
206
|
uiAutomatorSelector.push(`.resourceId("${this.formatIdLocator(ids[0])}")`);
|
|
251
207
|
}
|
|
252
|
-
|
|
253
|
-
// @ts-ignore This should work
|
|
254
|
-
const attributes = cssRule.items.filter(({ type }) => type === 'Attribute');
|
|
208
|
+
const attributes = items.filter(isAstAttribute);
|
|
255
209
|
for (const attr of attributes) {
|
|
256
210
|
uiAutomatorSelector.push(this.parseAttr(attr));
|
|
257
211
|
}
|
|
258
|
-
|
|
259
|
-
// @ts-ignore This should work
|
|
260
|
-
const pseudoClasses = cssRule.items.filter(({ type }) => type === 'PseudoClass');
|
|
212
|
+
const pseudoClasses = items.filter(isAstPseudoClass);
|
|
261
213
|
for (const pseudo of pseudoClasses) {
|
|
262
214
|
const sel = this.parsePseudo(pseudo);
|
|
263
215
|
if (sel) {
|
|
@@ -269,39 +221,12 @@ class CssConverter {
|
|
|
269
221
|
}
|
|
270
222
|
return uiAutomatorSelector.join('');
|
|
271
223
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Convert CSS object to UiAutomator2 selector
|
|
274
|
-
* @param {import('css-selector-parser').AstSelector} css CSS object
|
|
275
|
-
* @returns {string} The CSS object parsed as a UiSelector
|
|
276
|
-
*/
|
|
277
224
|
parseCssObject(css) {
|
|
278
225
|
if (!lodash_1.default.isEmpty(css.rules)) {
|
|
279
226
|
return this.parseCssRule(css.rules[0]);
|
|
280
227
|
}
|
|
281
228
|
throw new Error('No rules could be parsed out of the current selector');
|
|
282
229
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Convert a CSS selector to a UiAutomator2 selector
|
|
285
|
-
*
|
|
286
|
-
* @returns {string} The CSS selector converted to a UiSelector
|
|
287
|
-
*/
|
|
288
|
-
toUiAutomatorSelector() {
|
|
289
|
-
let cssObj;
|
|
290
|
-
try {
|
|
291
|
-
cssObj = parseCssSelector(this.selector);
|
|
292
|
-
}
|
|
293
|
-
catch (e) {
|
|
294
|
-
logger_1.default.debug(e.stack);
|
|
295
|
-
throw new driver_1.errors.InvalidSelectorError(`Invalid CSS selector '${this.selector}'. Reason: '${e.message}'`);
|
|
296
|
-
}
|
|
297
|
-
try {
|
|
298
|
-
return this.parseCssObject(cssObj);
|
|
299
|
-
}
|
|
300
|
-
catch (e) {
|
|
301
|
-
logger_1.default.debug(e.stack);
|
|
302
|
-
throw new driver_1.errors.InvalidSelectorError(`Unsupported CSS selector '${this.selector}'. Reason: '${e.message}'`);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
230
|
}
|
|
306
|
-
exports.
|
|
231
|
+
exports.CssConverter = CssConverter;
|
|
307
232
|
//# sourceMappingURL=css-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-converter.js","sourceRoot":"","sources":["../../lib/css-converter.
|
|
1
|
+
{"version":3,"file":"css-converter.js","sourceRoot":"","sources":["../../lib/css-converter.ts"],"names":[],"mappings":";;;;;;AAAA,6DAAiD;AAUjD,oDAAuB;AACvB,0CAAqC;AACrC,qCAA6B;AAE7B,MAAM,gBAAgB,GAAG,IAAA,kCAAY,EAAC;IACpC,MAAM,EAAE;QACN,aAAa,EAAE;YACb,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE;gBACX,QAAQ,EAAE,CAAC,KAAK,CAAC;aAClB;SACF;QACD,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QAC5B,UAAU,EAAE;YACV,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC;SACzC;QACD,GAAG,EAAE,IAAI;QACT,UAAU,EAAE,IAAI;QAChB,GAAG,EAAE;YACH,QAAQ,EAAE,IAAI;SACf;KACF;IACD,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAEjE,MAAM,aAAa,GAAG;IACpB,WAAW;IACX,SAAS;IACT,WAAW;IACX,SAAS;IACT,WAAW;IACX,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,UAAU;CACF,CAAC;AAEX,MAAM,a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,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAY,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;CACF;AAlKD,oCAkKC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const APK_EXTENSION: ".apk";
|
|
2
|
-
export const APKS_EXTENSION: ".apks";
|
|
1
|
+
export declare const APK_EXTENSION: ".apk";
|
|
2
|
+
export declare const APKS_EXTENSION: ".apks";
|
|
3
3
|
//# sourceMappingURL=extensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../lib/extensions.
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../lib/extensions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,EAAG,MAAe,CAAC;AAC7C,eAAO,MAAM,cAAc,EAAG,OAAgB,CAAC"}
|
package/build/lib/extensions.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.APKS_EXTENSION = exports.APK_EXTENSION = void 0;
|
|
4
|
-
|
|
5
|
-
exports.
|
|
6
|
-
const APKS_EXTENSION = '.apks';
|
|
7
|
-
exports.APKS_EXTENSION = APKS_EXTENSION;
|
|
4
|
+
exports.APK_EXTENSION = '.apk';
|
|
5
|
+
exports.APKS_EXTENSION = '.apks';
|
|
8
6
|
//# sourceMappingURL=extensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../lib/extensions.
|
|
1
|
+
{"version":3,"file":"extensions.js","sourceRoot":"","sources":["../../lib/extensions.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,MAAe,CAAC;AAChC,QAAA,cAAc,GAAG,OAAgB,CAAC"}
|
package/build/lib/helpers.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export function isWriteable(filePath: string): Promise<boolean>;
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {import('appium-adb').ADB} adb
|
|
9
|
-
* @param {string} appPath
|
|
10
|
-
* @returns {Promise<void>}
|
|
11
|
-
*/
|
|
12
|
-
export function signApp(adb: import("appium-adb").ADB, appPath: string): Promise<void>;
|
|
1
|
+
import type { ADB } from 'appium-adb';
|
|
2
|
+
export declare function isWriteable(filePath: string): Promise<boolean>;
|
|
3
|
+
export declare function signApp(adb: ADB, appPath: string): Promise<void>;
|
|
13
4
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers.
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,YAAY,CAAC;AAGpC,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcpE;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAStE"}
|
package/build/lib/helpers.js
CHANGED
|
@@ -7,10 +7,6 @@ exports.isWriteable = isWriteable;
|
|
|
7
7
|
exports.signApp = signApp;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const support_1 = require("appium/support");
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} filePath
|
|
12
|
-
* @returns {Promise<boolean>}
|
|
13
|
-
*/
|
|
14
10
|
async function isWriteable(filePath) {
|
|
15
11
|
try {
|
|
16
12
|
await support_1.fs.access(filePath, support_1.fs.constants.W_OK);
|
|
@@ -27,14 +23,8 @@ async function isWriteable(filePath) {
|
|
|
27
23
|
return false;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param {import('appium-adb').ADB} adb
|
|
33
|
-
* @param {string} appPath
|
|
34
|
-
* @returns {Promise<void>}
|
|
35
|
-
*/
|
|
36
26
|
async function signApp(adb, appPath) {
|
|
37
|
-
if (!await isWriteable(appPath)) {
|
|
27
|
+
if (!(await isWriteable(appPath))) {
|
|
38
28
|
throw new Error(`The application at '${appPath}' is not writeable. ` +
|
|
39
29
|
`Please grant write permissions to this file or to its parent folder '${path_1.default.dirname(appPath)}' ` +
|
|
40
30
|
`for the Appium process, so it could sign the application`);
|
package/build/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/helpers.
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/helpers.ts"],"names":[],"mappings":";;;;;AAIA,kCAcC;AAED,0BASC;AA7BD,gDAAwB;AAExB,4CAA0C;AAEnC,KAAK,UAAU,WAAW,CAAC,QAAgB;IAChD,IAAI,CAAC;QACH,MAAM,YAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,gBAAM,CAAC,SAAS,EAAE,EAAE,CAAC;YACvB,0DAA0D;YAC1D,6DAA6D;YAC7D,8EAA8E;YAC9E,mBAAmB;YACnB,MAAM,YAAE,CAAC,KAAK,CAAC,MAAM,YAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,GAAQ,EAAE,OAAe;IACrD,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,sBAAsB;YAClD,wEAAwE,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;YACjG,0DAA0D,CAC7D,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
package/build/lib/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,sCAAmC,CAAC"}
|
package/build/lib/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.log = void 0;
|
|
3
4
|
const support_1 = require("appium/support");
|
|
4
|
-
|
|
5
|
-
exports.default = log;
|
|
5
|
+
exports.log = support_1.logger.getLogger('UiAutomator2');
|
|
6
6
|
//# sourceMappingURL=logger.js.map
|
package/build/lib/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":";;;AAAA,4CAAsC;AAEzB,QAAA,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -64,7 +64,6 @@ export declare class UiAutomator2Server {
|
|
|
64
64
|
*/
|
|
65
65
|
private _waitForTermination;
|
|
66
66
|
}
|
|
67
|
-
export default UiAutomator2Server;
|
|
68
67
|
export interface PackageInfo {
|
|
69
68
|
installState: InstallState;
|
|
70
69
|
appPath: string;
|
|
@@ -79,4 +78,5 @@ export interface UiAutomator2ServerOptions {
|
|
|
79
78
|
disableSuppressAccessibilityService?: boolean;
|
|
80
79
|
basePath?: string;
|
|
81
80
|
}
|
|
81
|
+
export {};
|
|
82
82
|
//# sourceMappingURL=uiautomator2.d.ts.map
|