@applitools/driver 1.16.6 → 1.17.2
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 +26 -0
- package/dist/driver.js +8 -6
- package/dist/fake/mock-driver.js +15 -3
- package/dist/fake/spec-driver.js +6 -2
- package/package.json +3 -3
- package/types/driver.d.ts +1 -3
- package/types/fake/mock-driver.d.ts +26 -1
- package/types/fake/spec-driver.d.ts +1 -0
- package/types/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.17.2](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.1...js/driver@1.17.2) (2024-05-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* cache nml client per driver ([#2336](https://github.com/Applitools-Dev/sdk/issues/2336)) ([02c09a5](https://github.com/Applitools-Dev/sdk/commit/02c09a53eb6ca6340c93365908f4c485ab389c21))
|
|
9
|
+
|
|
10
|
+
## [1.17.1](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.0...js/driver@1.17.1) (2024-04-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* @applitools/utils bumped to 1.7.2
|
|
16
|
+
#### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* trigger release ([88ba29f](https://github.com/Applitools-Dev/sdk/commit/88ba29f358620a5c0f0861eb31e8929d0b611284))
|
|
19
|
+
* @applitools/logger bumped to 2.0.16
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.17.0](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.16.6...js/driver@1.17.0) (2024-04-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* report batchId and batchUrl to kobiton ([#2329](https://github.com/Applitools-Dev/sdk/issues/2329)) ([5be4356](https://github.com/Applitools-Dev/sdk/commit/5be4356d7f3cd96b70491325d4a788202c06720a))
|
|
28
|
+
|
|
3
29
|
## [1.16.6](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.16.5...js/driver@1.16.6) (2024-04-15)
|
|
4
30
|
|
|
5
31
|
|
package/dist/driver.js
CHANGED
|
@@ -34,6 +34,7 @@ const user_agent_1 = require("./user-agent");
|
|
|
34
34
|
const capabilities_1 = require("./capabilities");
|
|
35
35
|
const utils = __importStar(require("@applitools/utils"));
|
|
36
36
|
const snippets = require('@applitools/snippets');
|
|
37
|
+
const drivers = new WeakMap();
|
|
37
38
|
class Driver {
|
|
38
39
|
constructor(options) {
|
|
39
40
|
var _a, _b, _c, _d;
|
|
@@ -42,12 +43,14 @@ class Driver {
|
|
|
42
43
|
this._original = this;
|
|
43
44
|
this._logger = (0, logger_1.makeLogger)({ logger: options.logger, format: { label: 'driver' } });
|
|
44
45
|
this._customConfig = (_a = options.customConfig) !== null && _a !== void 0 ? _a : {};
|
|
45
|
-
this._guid = utils.general.guid();
|
|
46
46
|
this._spec = options.spec;
|
|
47
47
|
this._target = options.driver;
|
|
48
48
|
if (!this._spec.isDriver(this._target)) {
|
|
49
49
|
throw new TypeError('Driver constructor called with argument of unknown type!');
|
|
50
50
|
}
|
|
51
|
+
if (!drivers.get(options.driver)) {
|
|
52
|
+
drivers.set(options.driver, utils.general.guid());
|
|
53
|
+
}
|
|
51
54
|
this._mainContext = new context_1.Context({
|
|
52
55
|
spec: this._spec,
|
|
53
56
|
context: (_d = (_c = (_b = this._spec).extractContext) === null || _c === void 0 ? void 0 : _c.call(_b, this._target)) !== null && _d !== void 0 ? _d : this._target,
|
|
@@ -62,7 +65,7 @@ class Driver {
|
|
|
62
65
|
return this._target;
|
|
63
66
|
}
|
|
64
67
|
get guid() {
|
|
65
|
-
return this.
|
|
68
|
+
return drivers.get(this.target);
|
|
66
69
|
}
|
|
67
70
|
get currentContext() {
|
|
68
71
|
return this._currentContext;
|
|
@@ -277,8 +280,9 @@ class Driver {
|
|
|
277
280
|
this._environment.isMobile = true;
|
|
278
281
|
this._environment.isEmulation = true;
|
|
279
282
|
}
|
|
280
|
-
this.
|
|
281
|
-
|
|
283
|
+
const driverUrl = (_d = (await this.getDriverUrl())) !== null && _d !== void 0 ? _d : '';
|
|
284
|
+
this._environment.isEC = this._environment.isECClient || /exec-wus.applitools.com/.test(driverUrl);
|
|
285
|
+
this._environment.isKobiton = /kobiton/.test(driverUrl);
|
|
282
286
|
this._logger.log('Extracted environment', this._environment);
|
|
283
287
|
}
|
|
284
288
|
return this._environment;
|
|
@@ -867,8 +871,6 @@ async function makeDriver(options) {
|
|
|
867
871
|
let driver;
|
|
868
872
|
if (options.driver instanceof Driver) {
|
|
869
873
|
driver = options.driver;
|
|
870
|
-
if (options.relaxed)
|
|
871
|
-
return driver;
|
|
872
874
|
}
|
|
873
875
|
else {
|
|
874
876
|
options.driver = (_c = (await ((_b = (_a = options.spec) === null || _a === void 0 ? void 0 : _a.toDriver) === null || _b === void 0 ? void 0 : _b.call(_a, options.driver)))) !== null && _c !== void 0 ? _c : options.driver;
|
package/dist/fake/mock-driver.js
CHANGED
|
@@ -23,7 +23,7 @@ const DEFAULT_PROPS = {
|
|
|
23
23
|
};
|
|
24
24
|
class MockDriver {
|
|
25
25
|
constructor(options = {}) {
|
|
26
|
-
const { viewport = { width: 1000, height: 1000 }, device, platform, browser, ua } = options;
|
|
26
|
+
const { viewport = { width: 1000, height: 1000 }, device, platform, browser, ua, driverServerUrl, capabilities, } = options;
|
|
27
27
|
this._device = device;
|
|
28
28
|
this._platform = platform;
|
|
29
29
|
this._browser = browser;
|
|
@@ -33,6 +33,8 @@ class MockDriver {
|
|
|
33
33
|
url: 'http://default.url',
|
|
34
34
|
rect: { x: 0, y: 0, ...viewport },
|
|
35
35
|
};
|
|
36
|
+
this._driverServerUrl = driverServerUrl;
|
|
37
|
+
this._capabilities = capabilities;
|
|
36
38
|
this._methods = new Map();
|
|
37
39
|
this._scripts = new Map();
|
|
38
40
|
this._elements = new Map();
|
|
@@ -162,6 +164,9 @@ class MockDriver {
|
|
|
162
164
|
// TODO get window for context: `this.contexts.get(this._contextId)`
|
|
163
165
|
return { width: this._window.rect.width, height: this._window.rect.height };
|
|
164
166
|
});
|
|
167
|
+
this.mockScript('mobile:deviceScreenInfo', () => {
|
|
168
|
+
return { scale: 1, statusBarSize: { height: 1 } };
|
|
169
|
+
});
|
|
165
170
|
}
|
|
166
171
|
mockScript(scriptMatcher, resultGenerator) {
|
|
167
172
|
this._scripts.set(String(scriptMatcher), resultGenerator);
|
|
@@ -262,9 +267,16 @@ class MockDriver {
|
|
|
262
267
|
browserVersion: this._browser ? this._browser.version : null,
|
|
263
268
|
};
|
|
264
269
|
}
|
|
270
|
+
get driverServerUrl() {
|
|
271
|
+
return this._driverServerUrl;
|
|
272
|
+
}
|
|
273
|
+
get capabilities() {
|
|
274
|
+
return this._capabilities;
|
|
275
|
+
}
|
|
265
276
|
async executeScript(script, args = []) {
|
|
266
|
-
if (this.environment.isNative)
|
|
267
|
-
throw new Error(
|
|
277
|
+
if (this.environment.isNative && !/^mobile\:/.test(script)) {
|
|
278
|
+
throw new Error(`Native context doesn't support this method: ${script}`);
|
|
279
|
+
}
|
|
268
280
|
let result = this._scripts.get(String(script));
|
|
269
281
|
if (!result) {
|
|
270
282
|
const name = Object.keys(WELL_KNOWN_SCRIPTS).find(name => WELL_KNOWN_SCRIPTS[name](script));
|
package/dist/fake/spec-driver.js
CHANGED
|
@@ -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.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.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';
|
|
@@ -106,7 +106,7 @@ async function takeScreenshot(driver) {
|
|
|
106
106
|
}
|
|
107
107
|
exports.takeScreenshot = takeScreenshot;
|
|
108
108
|
async function getDriverInfo(driver) {
|
|
109
|
-
return { environment: driver.environment };
|
|
109
|
+
return { environment: driver.environment, driverServerUrl: driver.driverServerUrl };
|
|
110
110
|
}
|
|
111
111
|
exports.getDriverInfo = getDriverInfo;
|
|
112
112
|
async function getWindowSize(driver) {
|
|
@@ -153,3 +153,7 @@ async function performAction(_driver, _steps) {
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
exports.performAction = performAction;
|
|
156
|
+
async function getCapabilities(driver) {
|
|
157
|
+
return driver.capabilities;
|
|
158
|
+
}
|
|
159
|
+
exports.getCapabilities = getCapabilities;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/driver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.2",
|
|
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.
|
|
76
|
+
"@applitools/logger": "2.0.16",
|
|
77
77
|
"@applitools/snippets": "2.4.25",
|
|
78
|
-
"@applitools/utils": "1.7.
|
|
78
|
+
"@applitools/utils": "1.7.2",
|
|
79
79
|
"semver": "7.5.4"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
package/types/driver.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ type DriverOptions<T extends SpecType> = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare class Driver<T extends SpecType> {
|
|
19
19
|
private _target;
|
|
20
|
-
private _guid;
|
|
21
20
|
private _mainContext;
|
|
22
21
|
private _currentContext;
|
|
23
22
|
private _driverInfo?;
|
|
@@ -33,7 +32,7 @@ export declare class Driver<T extends SpecType> {
|
|
|
33
32
|
constructor(options: DriverOptions<T>);
|
|
34
33
|
get logger(): Logger;
|
|
35
34
|
get target(): T['driver'];
|
|
36
|
-
get guid(): string;
|
|
35
|
+
get guid(): string | undefined;
|
|
37
36
|
get currentContext(): Context<T>;
|
|
38
37
|
get mainContext(): Context<T>;
|
|
39
38
|
updateLogger(logger: Logger): void;
|
|
@@ -95,7 +94,6 @@ export declare function makeDriver<T extends SpecType>(options: {
|
|
|
95
94
|
useCeilForViewportSize?: boolean;
|
|
96
95
|
};
|
|
97
96
|
reset?: boolean;
|
|
98
|
-
relaxed?: boolean;
|
|
99
97
|
logger?: Logger;
|
|
100
98
|
}): Promise<Driver<T>>;
|
|
101
99
|
export {};
|
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
viewport?: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
device?: {
|
|
7
|
+
isMobile?: boolean;
|
|
8
|
+
isNative?: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
};
|
|
11
|
+
platform?: {
|
|
12
|
+
name?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
};
|
|
15
|
+
browser?: {
|
|
16
|
+
name?: string;
|
|
17
|
+
version?: string;
|
|
18
|
+
};
|
|
19
|
+
ua?: string;
|
|
20
|
+
driverServerUrl?: string;
|
|
21
|
+
capabilities?: Record<string, any>;
|
|
22
|
+
};
|
|
1
23
|
export declare class MockDriver {
|
|
2
|
-
constructor(options?:
|
|
24
|
+
constructor(options?: Options);
|
|
3
25
|
mockScript(scriptMatcher: any, resultGenerator: any): void;
|
|
4
26
|
mockElement(selector: any, state: any): any;
|
|
5
27
|
unmockElement(element: any): void;
|
|
@@ -23,6 +45,8 @@ export declare class MockDriver {
|
|
|
23
45
|
browserName: any;
|
|
24
46
|
browserVersion: any;
|
|
25
47
|
};
|
|
48
|
+
get driverServerUrl(): any;
|
|
49
|
+
get capabilities(): any;
|
|
26
50
|
executeScript(script: any, args?: never[]): Promise<any>;
|
|
27
51
|
findElement(selector: any, rootElement?: any): Promise<any>;
|
|
28
52
|
findElements(selector: any, rootElement?: any): Promise<any>;
|
|
@@ -38,3 +62,4 @@ export declare class MockDriver {
|
|
|
38
62
|
toJSON(): string;
|
|
39
63
|
getCurrentWorld(): Promise<"NATIVE_APP" | "WEBVIEW_1">;
|
|
40
64
|
}
|
|
65
|
+
export {};
|
|
@@ -39,4 +39,5 @@ export declare function getCurrentWorld(driver: Driver): Promise<any>;
|
|
|
39
39
|
export declare function getElementRegion(_driver: Driver, element: Element): Promise<Region>;
|
|
40
40
|
export declare function getElementAttribute(_driver: Driver, element: Element, attr: string): Promise<string>;
|
|
41
41
|
export declare function performAction(_driver: Driver, _steps: any[]): Promise<void>;
|
|
42
|
+
export declare function getCapabilities(driver: Driver): Promise<Record<string, any>>;
|
|
42
43
|
export {};
|