@applitools/driver 1.14.2 → 1.14.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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.14.4](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.14.3...js/driver@1.14.4) (2023-10-17)
4
+
5
+
6
+ ### Code Refactoring
7
+
8
+ * disallow usage of global Buffer ([#1957](https://github.com/applitools/eyes.sdk.javascript1/issues/1957)) ([adcc082](https://github.com/applitools/eyes.sdk.javascript1/commit/adcc082f20f6b92e819b96424e995d9a69d99758))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/utils bumped to 1.6.2
14
+ #### Code Refactoring
15
+
16
+ * disallow usage of global Buffer ([#1957](https://github.com/applitools/eyes.sdk.javascript1/issues/1957)) ([adcc082](https://github.com/applitools/eyes.sdk.javascript1/commit/adcc082f20f6b92e819b96424e995d9a69d99758))
17
+ * @applitools/logger bumped to 2.0.12
18
+ #### Code Refactoring
19
+
20
+ * disallow usage of global Buffer ([#1957](https://github.com/applitools/eyes.sdk.javascript1/issues/1957)) ([adcc082](https://github.com/applitools/eyes.sdk.javascript1/commit/adcc082f20f6b92e819b96424e995d9a69d99758))
21
+
22
+
23
+
24
+
25
+ ## [1.14.3](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.14.2...js/driver@1.14.3) (2023-09-29)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * force native on get environment ([#1939](https://github.com/applitools/eyes.sdk.javascript1/issues/1939)) ([f42854e](https://github.com/applitools/eyes.sdk.javascript1/commit/f42854eacc769751447204143cb4d50113edc732))
31
+
3
32
  ## [1.14.2](https://github.com/applitools/eyes.sdk.javascript1/compare/js/driver@1.14.1...js/driver@1.14.2) (2023-09-25)
4
33
 
5
34
 
package/dist/context.js CHANGED
@@ -145,7 +145,9 @@ class Context {
145
145
  else if (selector.shadow && !features.nestedSelectors) {
146
146
  elements = await elements.reduce((result, element) => {
147
147
  return result.then(async (result) => {
148
- const root = await this._spec.executeScript(this.target, snippets.getShadowRoot, [element]);
148
+ const root = await this._spec.executeScript(this.target, snippets.getShadowRoot, [
149
+ element,
150
+ ]);
149
151
  return result.concat(root ? await this._findElements(selector.shadow, { parent: root, all, wait }) : []);
150
152
  });
151
153
  }, Promise.resolve([]));
package/dist/driver.js CHANGED
@@ -27,6 +27,7 @@ exports.makeDriver = exports.isDriver = exports.isDriverInstance = exports.Drive
27
27
  const logger_1 = require("@applitools/logger");
28
28
  const context_1 = require("./context");
29
29
  const selector_1 = require("./selector");
30
+ const buffer_1 = require("buffer");
30
31
  const helper_ios_1 = require("./helper-ios");
31
32
  const helper_android_1 = require("./helper-android");
32
33
  const user_agent_1 = require("./user-agent");
@@ -220,9 +221,10 @@ class Driver {
220
221
  const capabilitiesEnvironment = capabilities ? (0, capabilities_1.extractCapabilitiesEnvironment)(capabilities) : null;
221
222
  this._logger.log('Extracted capabilities environment', capabilitiesEnvironment);
222
223
  this._environment = { ...this._environment, ...capabilitiesEnvironment };
223
- if (this._environment.isMobile && !this._environment.browserName) {
224
+ if (this._environment.isMobile) {
224
225
  const world = await this.getCurrentWorld();
225
- if (!!(world === null || world === void 0 ? void 0 : world.includes('WEBVIEW'))) {
226
+ this._environment.isNative = world === 'NATIVE_APP';
227
+ if (!!(world === null || world === void 0 ? void 0 : world.includes('WEBVIEW')) && !this._environment.browserName) {
226
228
  this._environment.isNative = true;
227
229
  this._environment.isWeb = true;
228
230
  }
@@ -511,7 +513,7 @@ class Driver {
511
513
  }
512
514
  try {
513
515
  await this._spec.switchWorld(this.target, name);
514
- this.refresh({ reset: true });
516
+ await this.refresh({ reset: true });
515
517
  }
516
518
  catch (error) {
517
519
  this._logger.error('Unable to switch world due to the error', error);
@@ -638,7 +640,7 @@ class Driver {
638
640
  async takeScreenshot() {
639
641
  const image = await this._spec.takeScreenshot(this.target);
640
642
  if (utils.types.isString(image)) {
641
- return Buffer.from(image.replace(/[\r\n]+/g, ''), 'base64');
643
+ return buffer_1.Buffer.from(image.replace(/[\r\n]+/g, ''), 'base64');
642
644
  }
643
645
  return image;
644
646
  }
@@ -362,5 +362,8 @@ class MockDriver {
362
362
  [inspect.custom]() {
363
363
  return '<MockDriver>';
364
364
  }
365
+ async getCurrentWorld() {
366
+ return this.environment.isNative ? 'NATIVE_APP' : 'WEBVIEW_1';
367
+ }
365
368
  }
366
369
  exports.MockDriver = MockDriver;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.visit = exports.getTitle = exports.getUrl = exports.getOrientation = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.getElementText = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.extractSelector = exports.toSimpleCommonSelector = exports.toSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
26
+ exports.getCurrentWorld = exports.visit = exports.getTitle = exports.getUrl = exports.getOrientation = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.getElementText = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.extractSelector = exports.toSimpleCommonSelector = exports.toSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
27
27
  const utils = __importStar(require("@applitools/utils"));
28
28
  function isDriver(driver) {
29
29
  return driver && driver.constructor.name === 'MockDriver';
@@ -137,3 +137,7 @@ async function visit(driver, url) {
137
137
  await driver.visit(url);
138
138
  }
139
139
  exports.visit = visit;
140
+ async function getCurrentWorld(driver) {
141
+ return driver.getCurrentWorld();
142
+ }
143
+ exports.getCurrentWorld = getCurrentWorld;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -73,9 +73,9 @@
73
73
  "test": "run --top-level mocha './test/**/*.spec.ts'"
74
74
  },
75
75
  "dependencies": {
76
- "@applitools/logger": "2.0.11",
76
+ "@applitools/logger": "2.0.12",
77
77
  "@applitools/snippets": "2.4.24",
78
- "@applitools/utils": "1.6.1",
78
+ "@applitools/utils": "1.6.2",
79
79
  "semver": "7.5.4"
80
80
  },
81
81
  "devDependencies": {
@@ -36,4 +36,5 @@ export declare class MockDriver {
36
36
  takeScreenshot(): Promise<unknown>;
37
37
  toString(): string;
38
38
  toJSON(): string;
39
+ getCurrentWorld(): Promise<"NATIVE_APP" | "WEBVIEW_1">;
39
40
  }
@@ -35,4 +35,5 @@ export declare function getOrientation(_driver: Driver): Promise<'portrait' | 'l
35
35
  export declare function getUrl(driver: Driver): Promise<string>;
36
36
  export declare function getTitle(driver: Driver): Promise<string>;
37
37
  export declare function visit(driver: Driver, url: string): Promise<void>;
38
+ export declare function getCurrentWorld(driver: Driver): Promise<any>;
38
39
  export {};