@applitools/driver 1.9.9 → 1.9.10

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.
@@ -28,7 +28,8 @@ const utils = __importStar(require("@applitools/utils"));
28
28
  class HelperAndroid {
29
29
  constructor(options) {
30
30
  this._spec = options.spec;
31
- this._element = options.element;
31
+ this._input = options.input;
32
+ this._action = options.action;
32
33
  this._legacy = options.legacy;
33
34
  this._logger = options.logger;
34
35
  this.name = this._legacy ? 'android-legacy' : 'android';
@@ -36,18 +37,17 @@ class HelperAndroid {
36
37
  static async make(options) {
37
38
  const { spec, driver, logger } = options;
38
39
  let legacy = false;
39
- let element = await driver.element({
40
- type: 'xpath',
41
- selector: '//*[@content-desc="EyesAppiumHelperEDT"]',
42
- });
43
- if (!element) {
40
+ let input = await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelperEDT"]' });
41
+ if (!input) {
44
42
  legacy = true;
45
- element = await driver.element({
46
- type: '-android uiautomator',
47
- selector: 'new UiSelector().description("EyesAppiumHelper")',
48
- });
43
+ input = await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelper"]' });
49
44
  }
50
- return element ? new HelperAndroid({ spec, element, legacy, logger }) : null;
45
+ const action = !legacy
46
+ ? await driver.element({ type: 'xpath', selector: '//*[@content-desc="EyesAppiumHelper_Action"]' })
47
+ : null;
48
+ return input
49
+ ? new HelperAndroid({ spec, input, action, legacy, logger })
50
+ : null;
51
51
  }
52
52
  async _getElementId(element) {
53
53
  const resourceId = await element.getAttribute('resource-id');
@@ -56,21 +56,25 @@ class HelperAndroid {
56
56
  return resourceId.split('/')[1];
57
57
  }
58
58
  async getContentSize(element) {
59
+ console.log('getContentSize', !!this._action);
59
60
  let contentHeightString;
60
61
  if (this._legacy) {
61
- await this._element.click();
62
- contentHeightString = await this._element.getText();
62
+ await this._input.click();
63
+ contentHeightString = await this._input.getText();
63
64
  }
64
65
  else {
65
66
  const elementId = await this._getElementId(element);
66
67
  if (!elementId)
67
68
  return null;
68
- await this._element.type(`offset;${elementId};0;0;0`);
69
- await this._element.click();
70
- contentHeightString = await this._element.getText();
71
- await this._element.type('');
69
+ await this._input.type(`offset;${elementId};0;0;0`);
70
+ if (this._action)
71
+ await this._action.type('1');
72
+ else
73
+ await this._input.click();
74
+ contentHeightString = await this._input.getText();
75
+ await this._input.type('');
72
76
  }
73
- const region = await this._spec.getElementRegion(this._element.driver.target, element.target);
77
+ const region = await this._spec.getElementRegion(this._input.driver.target, element.target);
74
78
  const contentHeight = Number(contentHeightString);
75
79
  if (Number.isNaN(contentHeight))
76
80
  return utils.geometry.size(region);
@@ -82,10 +86,13 @@ class HelperAndroid {
82
86
  const elementId = await this._getElementId(element);
83
87
  if (!elementId)
84
88
  return null;
85
- await this._element.type(`getRect;${elementId};0;0`);
86
- await this._element.click();
87
- const regionString = await this._element.getText();
88
- await this._element.type('');
89
+ await this._input.type(`getRect;${elementId};0;0`);
90
+ if (this._action)
91
+ await this._action.type('1');
92
+ else
93
+ await this._input.click();
94
+ const regionString = await this._input.getText();
95
+ await this._input.type('');
89
96
  const [, x, y, height, width] = regionString.match(/\[(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?);(-?\d+(?:\.\d+)?)\]/);
90
97
  const region = { x: Number(x), y: Number(y), width: Number(width), height: Number(height) };
91
98
  if (Number.isNaN(region.x + region.y + region.width + region.height))
@@ -98,9 +105,12 @@ class HelperAndroid {
98
105
  const elementId = await this._getElementId(element);
99
106
  if (!elementId)
100
107
  return null;
101
- await this._element.type(`moveToTop;${elementId};0;-1`);
102
- await this._element.click();
103
- await this._element.type('');
108
+ await this._input.type(`moveToTop;${elementId};0;-1`);
109
+ if (this._action)
110
+ await this._action.type('1');
111
+ else
112
+ await this._input.click();
113
+ await this._input.type('');
104
114
  }
105
115
  async scrollBy(element, offset) {
106
116
  if (this._legacy)
@@ -108,17 +118,23 @@ class HelperAndroid {
108
118
  const elementId = await this._getElementId(element);
109
119
  if (!elementId)
110
120
  return null;
111
- await this._element.type(`scroll;${elementId};${offset.y};0;0`);
112
- await this._element.click();
113
- await this._element.type('');
121
+ await this._input.type(`scroll;${elementId};${offset.y};0;0`);
122
+ if (this._action)
123
+ await this._action.type('1');
124
+ else
125
+ await this._input.click();
126
+ await this._input.type('');
114
127
  }
115
128
  async getTouchPadding() {
116
129
  if (this._legacy)
117
130
  return null;
118
- await this._element.type(`getTouchPadding;0;0;0;0`);
119
- await this._element.click();
120
- const touchPaddingString = await this._element.getText();
121
- await this._element.type('');
131
+ await this._input.type(`getTouchPadding;0;0;0;0`);
132
+ if (this._action)
133
+ await this._action.type('1');
134
+ else
135
+ await this._input.click();
136
+ const touchPaddingString = await this._input.getText();
137
+ await this._input.type('');
122
138
  const touchPadding = Number(touchPaddingString);
123
139
  if (Number.isNaN(touchPadding))
124
140
  return null;
@@ -40,10 +40,12 @@ function transformSelector(spec, selector, environment) {
40
40
  if ((environment === null || environment === void 0 ? void 0 : environment.isWeb) && isCommonSelector(spec, selector)) {
41
41
  if (selector.type === 'id')
42
42
  selector = { type: 'css', selector: `#${selector.selector}` };
43
- if (selector.type === 'name')
43
+ else if (selector.type === 'name')
44
44
  selector = { type: 'css', selector: `[name="${selector.selector}"]` };
45
- if (selector.type === 'class name')
45
+ else if (selector.type === 'class name')
46
46
  selector = { type: 'css', selector: `.${selector.selector}` };
47
+ else if (selector.type === 'tag name')
48
+ selector = { type: 'css', selector: `${selector.selector}` };
47
49
  }
48
50
  return (_b = (_a = spec.transformSelector) === null || _a === void 0 ? void 0 : _a.call(spec, selector)) !== null && _b !== void 0 ? _b : selector;
49
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.9.9",
3
+ "version": "1.9.10",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -17,7 +17,7 @@
17
17
  "repository": {
18
18
  "type": "git",
19
19
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
20
- "directory": "packages/driver"
20
+ "directory": "js/packages/driver"
21
21
  },
22
22
  "license": "SEE LICENSE IN LICENSE",
23
23
  "author": {
@@ -64,7 +64,9 @@
64
64
  "scripts": {
65
65
  "lint": "eslint '**/*.ts'",
66
66
  "build": "tsc",
67
- "test": "mocha --no-timeouts -r ts-node/register ./test/**/*.spec.ts",
67
+ "test": "yarn test:unit",
68
+ "test:sanity": "yarn test:unit",
69
+ "test:unit": "mocha --no-timeouts -r ts-node/register ./test/unit/*.spec.ts",
68
70
  "deps": "bongo deps",
69
71
  "preversion": "bongo preversion",
70
72
  "version": "bongo version",
@@ -82,7 +84,7 @@
82
84
  "@applitools/utils": "1.3.9"
83
85
  },
84
86
  "devDependencies": {
85
- "@applitools/bongo": "^2.1.5",
87
+ "@applitools/bongo": "^2.1.6",
86
88
  "@types/mocha": "^9.1.1",
87
89
  "@types/node": "^17.0.31",
88
90
  "@typescript-eslint/eslint-plugin": "^5.22.0",
@@ -9,13 +9,15 @@ export declare class HelperAndroid<TDriver, TContext, TElement, TSelector> {
9
9
  logger: Logger;
10
10
  }): Promise<HelperAndroid<TDriver, TContext, TElement, TSelector> | null>;
11
11
  private readonly _spec;
12
- private readonly _element;
12
+ private readonly _input;
13
+ private readonly _action?;
13
14
  private readonly _legacy;
14
15
  private _logger;
15
16
  readonly name: 'android' | 'android-legacy';
16
17
  constructor(options: {
17
18
  spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
18
- element: Element<TDriver, TContext, TElement, TSelector>;
19
+ input: Element<TDriver, TContext, TElement, TSelector>;
20
+ action?: Element<TDriver, TContext, TElement, TSelector>;
19
21
  legacy: boolean;
20
22
  logger?: any;
21
23
  });