@applitools/driver 1.17.1 → 1.17.3
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 +33 -0
- package/dist/driver.js +5 -2
- package/dist/fake/mock-driver.js +11 -3
- package/dist/fake/spec-driver.js +5 -1
- package/package.json +4 -4
- package/types/driver.d.ts +1 -2
- package/types/fake/mock-driver.d.ts +25 -1
- package/types/fake/spec-driver.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.17.3](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.2...js/driver@1.17.3) (2024-05-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* trigger release ([88c4f81](https://github.com/Applitools-Dev/sdk/commit/88c4f812bd92eae61ee8ebbee5da0d64ad8c8859))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* @applitools/utils bumped to 1.7.3
|
|
14
|
+
#### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* trigger release ([88c4f81](https://github.com/Applitools-Dev/sdk/commit/88c4f812bd92eae61ee8ebbee5da0d64ad8c8859))
|
|
17
|
+
* @applitools/logger bumped to 2.0.17
|
|
18
|
+
#### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* trigger release ([88c4f81](https://github.com/Applitools-Dev/sdk/commit/88c4f812bd92eae61ee8ebbee5da0d64ad8c8859))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
* @applitools/snippets bumped to 2.4.26
|
|
25
|
+
#### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* trigger release ([88c4f81](https://github.com/Applitools-Dev/sdk/commit/88c4f812bd92eae61ee8ebbee5da0d64ad8c8859))
|
|
28
|
+
|
|
29
|
+
## [1.17.2](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.1...js/driver@1.17.2) (2024-05-01)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* cache nml client per driver ([#2336](https://github.com/Applitools-Dev/sdk/issues/2336)) ([02c09a5](https://github.com/Applitools-Dev/sdk/commit/02c09a53eb6ca6340c93365908f4c485ab389c21))
|
|
35
|
+
|
|
3
36
|
## [1.17.1](https://github.com/Applitools-Dev/sdk/compare/js/driver@1.17.0...js/driver@1.17.1) (2024-04-22)
|
|
4
37
|
|
|
5
38
|
|
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;
|
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, driverServerUrl } = 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;
|
|
@@ -34,6 +34,7 @@ class MockDriver {
|
|
|
34
34
|
rect: { x: 0, y: 0, ...viewport },
|
|
35
35
|
};
|
|
36
36
|
this._driverServerUrl = driverServerUrl;
|
|
37
|
+
this._capabilities = capabilities;
|
|
37
38
|
this._methods = new Map();
|
|
38
39
|
this._scripts = new Map();
|
|
39
40
|
this._elements = new Map();
|
|
@@ -163,6 +164,9 @@ class MockDriver {
|
|
|
163
164
|
// TODO get window for context: `this.contexts.get(this._contextId)`
|
|
164
165
|
return { width: this._window.rect.width, height: this._window.rect.height };
|
|
165
166
|
});
|
|
167
|
+
this.mockScript('mobile:deviceScreenInfo', () => {
|
|
168
|
+
return { scale: 1, statusBarSize: { height: 1 } };
|
|
169
|
+
});
|
|
166
170
|
}
|
|
167
171
|
mockScript(scriptMatcher, resultGenerator) {
|
|
168
172
|
this._scripts.set(String(scriptMatcher), resultGenerator);
|
|
@@ -266,9 +270,13 @@ class MockDriver {
|
|
|
266
270
|
get driverServerUrl() {
|
|
267
271
|
return this._driverServerUrl;
|
|
268
272
|
}
|
|
273
|
+
get capabilities() {
|
|
274
|
+
return this._capabilities;
|
|
275
|
+
}
|
|
269
276
|
async executeScript(script, args = []) {
|
|
270
|
-
if (this.environment.isNative)
|
|
271
|
-
throw new Error(
|
|
277
|
+
if (this.environment.isNative && !/^mobile\:/.test(script)) {
|
|
278
|
+
throw new Error(`Native context doesn't support this method: ${script}`);
|
|
279
|
+
}
|
|
272
280
|
let result = this._scripts.get(String(script));
|
|
273
281
|
if (!result) {
|
|
274
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';
|
|
@@ -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.17.
|
|
3
|
+
"version": "1.17.3",
|
|
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.
|
|
77
|
-
"@applitools/snippets": "2.4.
|
|
78
|
-
"@applitools/utils": "1.7.
|
|
76
|
+
"@applitools/logger": "2.0.17",
|
|
77
|
+
"@applitools/snippets": "2.4.26",
|
|
78
|
+
"@applitools/utils": "1.7.3",
|
|
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;
|
|
@@ -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;
|
|
@@ -24,6 +46,7 @@ export declare class MockDriver {
|
|
|
24
46
|
browserVersion: any;
|
|
25
47
|
};
|
|
26
48
|
get driverServerUrl(): any;
|
|
49
|
+
get capabilities(): any;
|
|
27
50
|
executeScript(script: any, args?: never[]): Promise<any>;
|
|
28
51
|
findElement(selector: any, rootElement?: any): Promise<any>;
|
|
29
52
|
findElements(selector: any, rootElement?: any): Promise<any>;
|
|
@@ -39,3 +62,4 @@ export declare class MockDriver {
|
|
|
39
62
|
toJSON(): string;
|
|
40
63
|
getCurrentWorld(): Promise<"NATIVE_APP" | "WEBVIEW_1">;
|
|
41
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 {};
|