@applitools/driver 1.21.3 → 1.22.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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.22.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.21.4...js/driver@1.22.0) (2025-07-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * canvas webgl without preserveDrawingBuffer=1 | FLD-3144 ([#3040](https://github.com/Applitools-Dev/sdk/issues/3040)) ([f82d8f1](https://github.com/Applitools-Dev/sdk/commit/f82d8f148f913098752ec7bef8635a46b453d6fa))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/utils bumped to 1.9.0
14
+ #### Features
15
+
16
+ * support https_proxy and http_proxy env variables | FLD-2702 ([#3046](https://github.com/Applitools-Dev/sdk/issues/3046)) ([0633809](https://github.com/Applitools-Dev/sdk/commit/06338099f44bfb149a5829f62c2f9b19e2392850))
17
+ * @applitools/logger bumped to 2.1.5
18
+
19
+
20
+ ## [1.21.4](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.21.3...js/driver@1.21.4) (2025-05-11)
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * @applitools/utils bumped to 1.8.2
26
+ #### Bug Fixes
27
+
28
+ * remove redundant file readings and added rendering concurrency limit ([#2956](https://github.com/Applitools-Dev/sdk/issues/2956)) ([b970180](https://github.com/Applitools-Dev/sdk/commit/b97018010fdf12cb0d202192b22f643c16c569d5))
29
+ * @applitools/logger bumped to 2.1.4
30
+
31
+
3
32
  ## [1.21.3](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.21.2...js/driver@1.21.3) (2025-05-07)
4
33
 
5
34
 
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/context.js CHANGED
@@ -323,6 +323,9 @@ class Context {
323
323
  });
324
324
  return element ? (0, element_1.makeElement)({ spec: this._spec, context: this, element, selector }) : null;
325
325
  }
326
+ async executeBrowserCommands(driver, commands, _logger) {
327
+ return this._spec.executeBrowserCommands(driver, commands, this.logger);
328
+ }
326
329
  async execute(script, arg) {
327
330
  await this.focus();
328
331
  try {
package/dist/driver.js CHANGED
@@ -896,6 +896,15 @@ class Driver {
896
896
  throw new Error(`User function is not supported (${JSON.stringify(func)})`);
897
897
  }
898
898
  }
899
+ async addScriptToEvaluateOnNewDocument(script) {
900
+ const enableCommand = { command: 'Page.enable', params: null };
901
+ const addScriptToEvaluateOnNewDocumentCommand = {
902
+ command: 'Page.addScriptToEvaluateOnNewDocument',
903
+ params: { source: script, runImmediately: true },
904
+ };
905
+ const commands = [enableCommand, addScriptToEvaluateOnNewDocumentCommand];
906
+ return this._spec.executeBrowserCommands(this.target, commands, this._logger);
907
+ }
899
908
  async visit(url) {
900
909
  var _a, _b;
901
910
  await ((_b = (_a = this._spec).visit) === null || _b === void 0 ? void 0 : _b.call(_a, this.target, url));
@@ -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.executeUserFunction = exports.isUserFunction = exports.getCapabilities = exports.performAction = exports.getElementAttribute = exports.getElementRegion = 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;
26
+ exports.executeBrowserCommands = exports.executeUserFunction = exports.isUserFunction = exports.getCapabilities = exports.performAction = exports.getElementAttribute = exports.getElementRegion = 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';
@@ -165,3 +165,7 @@ async function executeUserFunction(_userFunction) {
165
165
  throw new Error(`executeUserFunction is not supported in FakeDriver. userFunction: ${_userFunction}`);
166
166
  }
167
167
  exports.executeUserFunction = executeUserFunction;
168
+ async function executeBrowserCommands(_driver, commands, _logger) {
169
+ throw new Error(`executeBrowserCommands is not supported in FakeDriver. script: ${commands}`);
170
+ }
171
+ exports.executeBrowserCommands = executeBrowserCommands;
package/dist/index.js CHANGED
@@ -20,3 +20,4 @@ __exportStar(require("./context"), exports);
20
20
  __exportStar(require("./element"), exports);
21
21
  __exportStar(require("./selector"), exports);
22
22
  __exportStar(require("./types"), exports);
23
+ __exportStar(require("./browser-command"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.21.3",
3
+ "version": "1.22.0",
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.1.3",
76
+ "@applitools/logger": "2.1.5",
77
77
  "@applitools/snippets": "2.6.5",
78
- "@applitools/utils": "1.8.1",
78
+ "@applitools/utils": "1.9.0",
79
79
  "semver": "7.6.2"
80
80
  },
81
81
  "devDependencies": {
@@ -0,0 +1,21 @@
1
+ interface BrowserBaseCommand {
2
+ 'Page.enable': null;
3
+ 'Page.addScriptToEvaluateOnNewDocument': {
4
+ source: string;
5
+ runImmediately?: boolean;
6
+ };
7
+ 'Network.getCookies': Record<string, never>;
8
+ 'Emulation.setDeviceMetricsOverride': {
9
+ width: number;
10
+ height: number;
11
+ deviceScaleFactor?: number;
12
+ mobile?: boolean;
13
+ };
14
+ }
15
+ export type BrowserCommand = {
16
+ [K in keyof BrowserBaseCommand]: {
17
+ command: K;
18
+ params: BrowserBaseCommand[K];
19
+ };
20
+ }[keyof BrowserBaseCommand];
21
+ export {};
@@ -4,6 +4,7 @@ import { type SpecType, type SpecDriver, type WaitOptions } from './spec-driver'
4
4
  import { type Driver } from './driver';
5
5
  import { type Selector } from './selector';
6
6
  import { type ElementReference, type Element } from './element';
7
+ import { BrowserCommand } from './browser-command';
7
8
  export type ContextReference<T extends SpecType> = Element<T> | ElementReference<T> | string | number;
8
9
  export type NestedContextReference<T extends SpecType> = {
9
10
  reference: ContextReference<T>;
@@ -55,6 +56,7 @@ export declare class Context<T extends SpecType> {
55
56
  element(elementOrSelector: ElementReference<T>): Promise<Element<T> | null>;
56
57
  elements(selectorOrElement: ElementReference<T>): Promise<Element<T>[]>;
57
58
  waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
59
+ executeBrowserCommands(driver: any, commands: BrowserCommand[], _logger?: any): Promise<any>;
58
60
  execute(script: ((args: any) => any) | string, arg?: any): Promise<any>;
59
61
  executePoll(script: ((arg: any) => any) | string | {
60
62
  main: ((arg: any) => any) | string;
package/types/driver.d.ts CHANGED
@@ -103,6 +103,7 @@ export declare class Driver<T extends SpecType> {
103
103
  waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
104
104
  execute(script: ((arg: any) => any) | string, arg?: any): Promise<any>;
105
105
  executeUserFunction<T>(func: SpecType['userFunction'] | (() => T)): Promise<any>;
106
+ addScriptToEvaluateOnNewDocument(script: string): Promise<any>;
106
107
  visit(url: string): Promise<void>;
107
108
  }
108
109
  export declare function isDriverInstance<T extends SpecType>(driver: any): driver is Driver<T>;
@@ -1,5 +1,7 @@
1
1
  import type { Region, Size } from '@applitools/utils';
2
2
  import type { DriverInfo } from '../types';
3
+ import { BrowserCommand } from '../browser-command';
4
+ import { Logger } from '@applitools/logger';
3
5
  export type Driver = any;
4
6
  export type Element = any;
5
7
  export type Selector = string | {
@@ -42,4 +44,5 @@ export declare function performAction(_driver: Driver, _steps: any[]): Promise<v
42
44
  export declare function getCapabilities(driver: Driver): Promise<Record<string, any>>;
43
45
  export declare function isUserFunction(_ref: any): Promise<boolean>;
44
46
  export declare function executeUserFunction(_userFunction: any): Promise<void>;
47
+ export declare function executeBrowserCommands(_driver: Driver, commands: BrowserCommand[], _logger?: Logger): Promise<any>;
45
48
  export {};
package/types/index.d.ts CHANGED
@@ -4,3 +4,4 @@ export * from './context';
4
4
  export * from './element';
5
5
  export * from './selector';
6
6
  export * from './types';
7
+ export * from './browser-command';
@@ -1,6 +1,8 @@
1
1
  import type { Size, Region } from '@applitools/utils';
2
2
  import type { DriverInfo, Capabilities, ScreenOrientation, Cookie } from './types';
3
3
  import { type CommonSelector } from './selector';
4
+ import type { Logger } from '@applitools/logger';
5
+ import { BrowserCommand } from './browser-command';
4
6
  export type SpecType<TDriver = unknown, TContext = unknown, TElement = unknown, TSelector = unknown, TSecondary extends SpecType = SpecType<unknown, unknown, unknown, unknown, never>, UserFunction = unknown> = {
5
7
  driver: TDriver;
6
8
  context: TContext;
@@ -85,6 +87,7 @@ export interface SpecDriver<T extends SpecType> {
85
87
  executeScript(context: T['context'], script: ((arg?: any) => any) | string, arg?: any): Promise<any>;
86
88
  isUserFunction?(ref: any): Promise<boolean>;
87
89
  executeUserFunction?(userFunction: T['userFunction']): Promise<any>;
90
+ executeBrowserCommands(driver: T['driver'], commands: BrowserCommand[], logger?: Logger): Promise<any>;
88
91
  findElement(context: T['context'], selector: T['selector'], parent?: T['element']): Promise<T['element'] | null>;
89
92
  findElements(context: T['context'], selector: T['selector'], parent?: T['element']): Promise<T['element'][]>;
90
93
  waitForSelector?(context: T['context'], selector: T['selector'], parent?: T['element'], options?: WaitOptions): Promise<T['element'] | null>;