@applitools/driver 1.11.37 → 1.11.38
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/dist/capabilities.js +34 -27
- package/dist/context.js +15 -9
- package/dist/driver.js +394 -430
- package/dist/element.js +68 -44
- package/dist/fake/mock-driver.js +9 -12
- package/dist/fake/spec-driver.js +1 -1
- package/dist/user-agent.js +51 -12
- package/package.json +3 -3
- package/types/capabilities.d.ts +3 -4
- package/types/driver.d.ts +35 -51
- package/types/fake/mock-driver.d.ts +1 -1
- package/types/fake/spec-driver.d.ts +1 -1
- package/types/spec-driver.d.ts +3 -39
- package/types/types.d.ts +61 -0
- package/types/user-agent.d.ts +2 -12
- package/dist/user-agent-data.js +0 -33
- package/types/user-agent-data.d.ts +0 -13
package/types/driver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Size, Region } from '@applitools/utils';
|
|
3
|
-
import type { ScreenOrientation, Cookie } from './types';
|
|
3
|
+
import type { DriverInfo, Capabilities, UserAgent, Environment, Viewport, Features, ScreenOrientation, Cookie } from './types';
|
|
4
4
|
import { type Selector } from './selector';
|
|
5
5
|
import { type SpecType, type SpecDriver, type WaitOptions } from './spec-driver';
|
|
6
6
|
import { type Element } from './element';
|
|
@@ -18,92 +18,76 @@ type DriverOptions<T extends SpecType> = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare class Driver<T extends SpecType> {
|
|
20
20
|
private _target;
|
|
21
|
+
private _guid;
|
|
21
22
|
private _mainContext;
|
|
22
23
|
private _currentContext;
|
|
23
|
-
private _driverInfo
|
|
24
|
+
private _driverInfo?;
|
|
25
|
+
private _environment?;
|
|
26
|
+
private _viewport?;
|
|
27
|
+
private _features?;
|
|
24
28
|
private _helper?;
|
|
25
29
|
private _state;
|
|
26
|
-
private _logger;
|
|
27
30
|
private _customConfig;
|
|
31
|
+
private _logger;
|
|
28
32
|
protected readonly _spec: SpecDriver<T>;
|
|
29
33
|
constructor(options: DriverOptions<T>);
|
|
30
34
|
get target(): T['driver'];
|
|
35
|
+
get guid(): string;
|
|
31
36
|
get currentContext(): Context<T>;
|
|
32
37
|
get mainContext(): Context<T>;
|
|
33
|
-
get features(): {
|
|
34
|
-
shadowSelector?: boolean | undefined;
|
|
35
|
-
allCookies?: boolean | undefined;
|
|
36
|
-
canExecuteOnlyFunctionScripts?: boolean | undefined;
|
|
37
|
-
} | undefined;
|
|
38
|
-
get deviceName(): string | undefined;
|
|
39
|
-
get platformName(): string | undefined;
|
|
40
|
-
get platformVersion(): string | number | undefined;
|
|
41
|
-
get browserName(): string | undefined;
|
|
42
|
-
get browserVersion(): string | number | undefined;
|
|
43
|
-
get userAgent(): string | undefined;
|
|
44
|
-
get orientation(): ScreenOrientation | undefined;
|
|
45
|
-
get pixelRatio(): number;
|
|
46
|
-
get viewportScale(): number;
|
|
47
|
-
get statusBarSize(): number | undefined;
|
|
48
|
-
get navigationBarSize(): number | undefined;
|
|
49
|
-
get isNative(): boolean;
|
|
50
|
-
get isWebView(): boolean;
|
|
51
|
-
get isWeb(): boolean;
|
|
52
|
-
get isEmulation(): boolean;
|
|
53
|
-
get isMobile(): boolean;
|
|
54
|
-
get isIOS(): boolean;
|
|
55
|
-
get isAndroid(): boolean;
|
|
56
|
-
get isMac(): boolean;
|
|
57
|
-
get isWindows(): boolean;
|
|
58
|
-
get isChromium(): boolean;
|
|
59
|
-
get isIE(): boolean;
|
|
60
|
-
get isEdgeLegacy(): boolean;
|
|
61
|
-
get isECClient(): boolean;
|
|
62
|
-
get isEC(): boolean;
|
|
63
|
-
get sessionId(): string | undefined;
|
|
64
|
-
get remoteHostname(): string | undefined;
|
|
65
38
|
updateCurrentContext(context: Context<T>): void;
|
|
66
|
-
|
|
39
|
+
refresh(): Promise<this>;
|
|
40
|
+
getDriverInfo({ force }?: {
|
|
41
|
+
force?: boolean;
|
|
42
|
+
}): Promise<DriverInfo>;
|
|
43
|
+
getCapabilities({ force }?: {
|
|
44
|
+
force?: boolean;
|
|
45
|
+
}): Promise<Capabilities | null>;
|
|
46
|
+
getUserAgent({ force }?: {
|
|
47
|
+
force?: boolean;
|
|
48
|
+
}): Promise<UserAgent | null>;
|
|
49
|
+
getUserAgentLegacy({ force }?: {
|
|
50
|
+
force?: boolean;
|
|
51
|
+
}): Promise<string | null>;
|
|
52
|
+
getEnvironment(): Promise<Environment>;
|
|
53
|
+
getViewport(): Promise<Viewport>;
|
|
54
|
+
getFeatures(): Promise<Features>;
|
|
55
|
+
getSessionId(): Promise<string | null>;
|
|
56
|
+
getDriverUrl(): Promise<string | null>;
|
|
67
57
|
getHelper(): Promise<HelperAndroid<T> | HelperIOS<T> | null>;
|
|
68
58
|
extractBrokerUrl(): Promise<string | null>;
|
|
69
|
-
|
|
70
|
-
id?: string;
|
|
71
|
-
restoreState?: boolean;
|
|
72
|
-
goHome?: boolean;
|
|
73
|
-
}): Promise<void>;
|
|
59
|
+
getSessionMetadata(): Promise<any | undefined>;
|
|
74
60
|
getWorlds(): Promise<string[] | null>;
|
|
75
61
|
getCurrentWorld(): Promise<string | null>;
|
|
76
|
-
|
|
77
|
-
refreshContexts(): Promise<Context<T>>;
|
|
62
|
+
switchWorld(name?: string): Promise<void>;
|
|
78
63
|
switchTo(context: Context<T>): Promise<Context<T>>;
|
|
79
64
|
switchToMainContext(): Promise<Context<T>>;
|
|
80
65
|
switchToParentContext(elevation?: number): Promise<Context<T>>;
|
|
81
66
|
switchToChildContext(...references: ContextReference<T>[]): Promise<Context<T>>;
|
|
82
67
|
normalizeRegion(region: Region): Promise<Region>;
|
|
83
68
|
getRegionInViewport(context: Context<T>, region: Region): Promise<Region>;
|
|
84
|
-
element(selector: Selector<T>): Promise<Element<T> | null>;
|
|
85
|
-
elements(selector: Selector<T>): Promise<Element<T>[]>;
|
|
86
|
-
waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
|
|
87
|
-
execute(script: ((arg: any) => any) | string, arg?: any): Promise<any>;
|
|
88
69
|
takeScreenshot(): Promise<Buffer>;
|
|
89
|
-
getViewportRegion(): Promise<Region>;
|
|
90
70
|
getViewportSize(): Promise<Size>;
|
|
91
71
|
setViewportSize(size: Size): Promise<void>;
|
|
92
|
-
getDisplaySize(): Promise<Size>;
|
|
93
|
-
getOrientation(): Promise<ScreenOrientation>;
|
|
72
|
+
getDisplaySize(): Promise<Size | undefined>;
|
|
73
|
+
getOrientation(): Promise<ScreenOrientation | undefined>;
|
|
94
74
|
setOrientation(orientation: 'portrait' | 'landscape'): Promise<void>;
|
|
95
75
|
getCookies(): Promise<Cookie[]>;
|
|
96
76
|
getTitle(): Promise<string>;
|
|
97
77
|
getUrl(): Promise<string>;
|
|
78
|
+
element(selector: Selector<T>): Promise<Element<T> | null>;
|
|
79
|
+
elements(selector: Selector<T>): Promise<Element<T>[]>;
|
|
80
|
+
waitFor(selector: Selector<T>, options?: WaitOptions): Promise<Element<T> | null>;
|
|
81
|
+
execute(script: ((arg: any) => any) | string, arg?: any): Promise<any>;
|
|
98
82
|
visit(url: string): Promise<void>;
|
|
99
83
|
}
|
|
100
84
|
export declare function isDriver<T extends SpecType>(driver: any, spec?: SpecDriver<T>): driver is Driver<T> | T['driver'];
|
|
101
85
|
export declare function makeDriver<T extends SpecType>(options: {
|
|
102
86
|
driver: Driver<T> | T['driver'];
|
|
103
87
|
spec?: SpecDriver<T>;
|
|
104
|
-
logger?: Logger;
|
|
105
88
|
customConfig?: {
|
|
106
89
|
useCeilForViewportSize?: boolean;
|
|
107
90
|
};
|
|
91
|
+
logger?: Logger;
|
|
108
92
|
}): Promise<Driver<T>>;
|
|
109
93
|
export {};
|
|
@@ -14,7 +14,7 @@ export declare class MockDriver {
|
|
|
14
14
|
[K in keyof MockDriver]: MockDriver[K] extends (...args: any[]) => any ? K : never;
|
|
15
15
|
}[keyof MockDriver]>(name: TName, wrapper: (method: this[TName], thisArg: this, args: Parameters<this[TName]>) => ReturnType<this[TName]>): void;
|
|
16
16
|
unwrapMethod(name: any): void;
|
|
17
|
-
get
|
|
17
|
+
get environment(): {
|
|
18
18
|
isMobile: boolean;
|
|
19
19
|
isNative: boolean;
|
|
20
20
|
deviceName: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Size } from '@applitools/utils';
|
|
3
|
-
import {
|
|
3
|
+
import type { DriverInfo } from '../types';
|
|
4
4
|
export type Driver = any;
|
|
5
5
|
export type Element = any;
|
|
6
6
|
export type Selector = string | {
|
package/types/spec-driver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type {
|
|
3
|
-
import type { ScreenOrientation, Cookie } from './types';
|
|
2
|
+
import type { Size, Region } from '@applitools/utils';
|
|
3
|
+
import type { DriverInfo, Capabilities, ScreenOrientation, Cookie } from './types';
|
|
4
4
|
import { type CommonSelector } from './selector';
|
|
5
5
|
export type SpecType<TDriver = unknown, TContext = unknown, TElement = unknown, TSelector = unknown> = {
|
|
6
6
|
driver: TDriver;
|
|
@@ -37,7 +37,7 @@ export interface SpecDriver<T extends SpecType> {
|
|
|
37
37
|
getViewportSize?(driver: T['driver']): Promise<Size>;
|
|
38
38
|
getCookies?(driver: T['driver'] | T['context'], context?: boolean): Promise<Cookie[]>;
|
|
39
39
|
getDriverInfo?(driver: T['driver']): Promise<DriverInfo>;
|
|
40
|
-
getCapabilities?(driver: T['driver']): Promise<
|
|
40
|
+
getCapabilities?(driver: T['driver']): Promise<Capabilities>;
|
|
41
41
|
getTitle(driver: T['driver']): Promise<string>;
|
|
42
42
|
getUrl(driver: T['driver']): Promise<string>;
|
|
43
43
|
takeScreenshot(driver: T['driver']): Promise<Buffer | string>;
|
|
@@ -69,42 +69,6 @@ export interface SpecDriver<T extends SpecType> {
|
|
|
69
69
|
switchWorld?(driver: T['driver'], id: string): Promise<void>;
|
|
70
70
|
getSessionMetadata?(driver: T['driver']): Promise<any>;
|
|
71
71
|
}
|
|
72
|
-
export type DriverInfo = {
|
|
73
|
-
sessionId?: string;
|
|
74
|
-
remoteHostname?: string;
|
|
75
|
-
browserName?: string;
|
|
76
|
-
browserVersion?: string;
|
|
77
|
-
platformName?: string;
|
|
78
|
-
platformVersion?: string;
|
|
79
|
-
deviceName?: string;
|
|
80
|
-
userAgent?: string;
|
|
81
|
-
viewportLocation?: Location;
|
|
82
|
-
viewportSize?: Size;
|
|
83
|
-
displaySize?: Size;
|
|
84
|
-
orientation?: ScreenOrientation;
|
|
85
|
-
pixelRatio?: number;
|
|
86
|
-
viewportScale?: number;
|
|
87
|
-
safeArea?: Region;
|
|
88
|
-
statusBarSize?: number;
|
|
89
|
-
navigationBarSize?: number;
|
|
90
|
-
isW3C?: boolean;
|
|
91
|
-
isChrome?: boolean;
|
|
92
|
-
isChromium?: boolean;
|
|
93
|
-
isEmulation?: boolean;
|
|
94
|
-
isMobile?: boolean;
|
|
95
|
-
isNative?: boolean;
|
|
96
|
-
isAndroid?: boolean;
|
|
97
|
-
isIOS?: boolean;
|
|
98
|
-
isMac?: boolean;
|
|
99
|
-
isWindows?: boolean;
|
|
100
|
-
isWebView?: boolean;
|
|
101
|
-
isECClient?: boolean;
|
|
102
|
-
features?: {
|
|
103
|
-
shadowSelector?: boolean;
|
|
104
|
-
allCookies?: boolean;
|
|
105
|
-
canExecuteOnlyFunctionScripts?: boolean;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
72
|
export type WaitOptions = {
|
|
109
73
|
state?: 'exist' | 'visible';
|
|
110
74
|
interval?: number;
|
package/types/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Location, Size, Region } from '@applitools/utils';
|
|
1
2
|
export type ScreenOrientation = 'portrait' | 'landscape' | 'portrait-secondary' | 'landscape-secondary';
|
|
2
3
|
export type Cookie = {
|
|
3
4
|
name: string;
|
|
@@ -9,3 +10,63 @@ export type Cookie = {
|
|
|
9
10
|
secure?: boolean;
|
|
10
11
|
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
11
12
|
};
|
|
13
|
+
export type Capabilities = Record<string, any>;
|
|
14
|
+
export type UserAgent = string | {
|
|
15
|
+
legacy: string;
|
|
16
|
+
brands: {
|
|
17
|
+
brand: string;
|
|
18
|
+
version: string;
|
|
19
|
+
}[];
|
|
20
|
+
platform: string;
|
|
21
|
+
platformVersion?: string;
|
|
22
|
+
model?: string;
|
|
23
|
+
mobile?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type Environment = {
|
|
26
|
+
browserName?: string;
|
|
27
|
+
browserVersion?: string;
|
|
28
|
+
platformName?: string;
|
|
29
|
+
platformVersion?: string;
|
|
30
|
+
deviceName?: string;
|
|
31
|
+
isW3C?: boolean;
|
|
32
|
+
isEC?: boolean;
|
|
33
|
+
isECClient?: boolean;
|
|
34
|
+
isWeb?: boolean;
|
|
35
|
+
isNative?: boolean;
|
|
36
|
+
isMobile?: boolean;
|
|
37
|
+
isEmulation?: boolean;
|
|
38
|
+
isIE?: boolean;
|
|
39
|
+
isEdge?: boolean;
|
|
40
|
+
isEdgeLegacy?: boolean;
|
|
41
|
+
isChrome?: boolean;
|
|
42
|
+
isChromium?: boolean;
|
|
43
|
+
isAndroid?: boolean;
|
|
44
|
+
isIOS?: boolean;
|
|
45
|
+
isMac?: boolean;
|
|
46
|
+
isWindows?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type Viewport = {
|
|
49
|
+
displaySize?: Size;
|
|
50
|
+
viewportSize: Size;
|
|
51
|
+
viewportLocation?: Location;
|
|
52
|
+
orientation?: ScreenOrientation;
|
|
53
|
+
pixelRatio: number;
|
|
54
|
+
viewportScale: number;
|
|
55
|
+
statusBarSize?: number;
|
|
56
|
+
navigationBarSize?: number;
|
|
57
|
+
safeArea?: Region;
|
|
58
|
+
};
|
|
59
|
+
export type Features = {
|
|
60
|
+
shadowSelector?: boolean;
|
|
61
|
+
allCookies?: boolean;
|
|
62
|
+
canExecuteOnlyFunctionScripts?: boolean;
|
|
63
|
+
};
|
|
64
|
+
export type DriverInfo = {
|
|
65
|
+
sessionId?: string;
|
|
66
|
+
remoteHostname?: string;
|
|
67
|
+
userAgent?: UserAgent | null;
|
|
68
|
+
capabilities?: Capabilities | null;
|
|
69
|
+
viewport?: Partial<Viewport>;
|
|
70
|
+
environment?: Partial<Environment>;
|
|
71
|
+
features?: Features;
|
|
72
|
+
};
|
package/types/user-agent.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
platformVersion?: string;
|
|
4
|
-
};
|
|
5
|
-
type BrowserInfo = {
|
|
6
|
-
browserName: string;
|
|
7
|
-
browserVersion?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function parseUserAgent(userAgent: string): PlatformInfo & BrowserInfo;
|
|
10
|
-
export declare function parsePlatform(userAgent: string): PlatformInfo;
|
|
11
|
-
export declare function parseBrowser(userAgent: string): BrowserInfo;
|
|
12
|
-
export {};
|
|
1
|
+
import type { UserAgent, Environment } from './types';
|
|
2
|
+
export declare function extractUserAgentEnvironment(userAgent: UserAgent): Environment;
|
package/dist/user-agent-data.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseUserAgentData = void 0;
|
|
4
|
-
const WINDOWS_VERSIONS = {
|
|
5
|
-
'0.1.0': '7',
|
|
6
|
-
'0.2.0': '8',
|
|
7
|
-
'0.3.0': '8.1',
|
|
8
|
-
'10.0.0': '10',
|
|
9
|
-
'15.0.0': '11',
|
|
10
|
-
};
|
|
11
|
-
function parseUserAgentData(userAgentData) {
|
|
12
|
-
var _a, _b, _c, _d;
|
|
13
|
-
const chromiumBrand = (_a = userAgentData.brands) === null || _a === void 0 ? void 0 : _a.find(brand => /Chromium/i.test(brand.brand));
|
|
14
|
-
const browserBrand = (_c = (_b = userAgentData.brands) === null || _b === void 0 ? void 0 : _b.find(brand => brand !== chromiumBrand && !/Not.?A.?Brand/i.test(brand.brand))) !== null && _c !== void 0 ? _c : chromiumBrand;
|
|
15
|
-
const info = {
|
|
16
|
-
browserName: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.brand,
|
|
17
|
-
browserVersion: browserBrand === null || browserBrand === void 0 ? void 0 : browserBrand.version,
|
|
18
|
-
platformName: userAgentData.platform || undefined,
|
|
19
|
-
platformVersion: userAgentData.platformVersion || undefined,
|
|
20
|
-
deviceName: userAgentData.model || undefined,
|
|
21
|
-
isMobile: userAgentData.mobile,
|
|
22
|
-
isChromium: Boolean(chromiumBrand),
|
|
23
|
-
};
|
|
24
|
-
if (info.platformName === 'Windows') {
|
|
25
|
-
info.platformVersion = WINDOWS_VERSIONS[info.platformVersion];
|
|
26
|
-
}
|
|
27
|
-
else if (info.platformName === 'macOS') {
|
|
28
|
-
info.platformName = 'Mac OS X';
|
|
29
|
-
info.platformVersion = (_d = info.platformVersion) === null || _d === void 0 ? void 0 : _d.split(/[._]/, 2).join('.');
|
|
30
|
-
}
|
|
31
|
-
return info;
|
|
32
|
-
}
|
|
33
|
-
exports.parseUserAgentData = parseUserAgentData;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type DriverInfo } from './spec-driver';
|
|
2
|
-
type UserAgentData = {
|
|
3
|
-
brands: {
|
|
4
|
-
brand: string;
|
|
5
|
-
version: string;
|
|
6
|
-
}[];
|
|
7
|
-
platform: string;
|
|
8
|
-
platformVersion?: string;
|
|
9
|
-
model?: string;
|
|
10
|
-
mobile?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export declare function parseUserAgentData(userAgentData: UserAgentData): DriverInfo;
|
|
13
|
-
export {};
|