@applitools/spec-driver-playwright 1.3.7 → 1.3.9
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/spec-driver.js +28 -18
- package/package.json +8 -26
- package/types/index.d.ts +10 -9
package/dist/spec-driver.js
CHANGED
|
@@ -126,32 +126,35 @@ async function mainContext(frame) {
|
|
|
126
126
|
}
|
|
127
127
|
exports.mainContext = mainContext;
|
|
128
128
|
async function parentContext(frame) {
|
|
129
|
+
var _a;
|
|
129
130
|
frame = extractContext(frame);
|
|
130
|
-
return frame.parentFrame();
|
|
131
|
+
return (_a = frame.parentFrame()) !== null && _a !== void 0 ? _a : frame;
|
|
131
132
|
}
|
|
132
133
|
exports.parentContext = parentContext;
|
|
133
134
|
async function childContext(_frame, element) {
|
|
134
|
-
|
|
135
|
+
const frame = (await element.contentFrame());
|
|
136
|
+
return frame;
|
|
135
137
|
}
|
|
136
138
|
exports.childContext = childContext;
|
|
137
139
|
async function findElement(frame, selector, parent) {
|
|
138
|
-
if (utils.types.instanceOf(selector, 'Locator'))
|
|
140
|
+
if (utils.types.instanceOf(selector, 'Locator')) {
|
|
139
141
|
return selector.elementHandle();
|
|
142
|
+
}
|
|
140
143
|
const root = parent !== null && parent !== void 0 ? parent : frame;
|
|
141
144
|
return root.$(selector);
|
|
142
145
|
}
|
|
143
146
|
exports.findElement = findElement;
|
|
144
147
|
async function findElements(frame, selector, parent) {
|
|
145
|
-
if (utils.types.instanceOf(selector, 'Locator'))
|
|
146
|
-
return selector.elementHandles();
|
|
148
|
+
if (utils.types.instanceOf(selector, 'Locator')) {
|
|
149
|
+
return (await selector.elementHandles());
|
|
150
|
+
}
|
|
147
151
|
const root = parent !== null && parent !== void 0 ? parent : frame;
|
|
148
152
|
return root.$$(selector);
|
|
149
153
|
}
|
|
150
154
|
exports.findElements = findElements;
|
|
151
155
|
async function setElementText(frame, element, text) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
await element.fill(text);
|
|
156
|
+
const resolvedElement = isSelector(element) ? await findElement(frame, element) : element;
|
|
157
|
+
await (resolvedElement === null || resolvedElement === void 0 ? void 0 : resolvedElement.fill(text));
|
|
155
158
|
}
|
|
156
159
|
exports.setElementText = setElementText;
|
|
157
160
|
async function getViewportSize(page) {
|
|
@@ -192,22 +195,21 @@ async function takeScreenshot(page) {
|
|
|
192
195
|
}
|
|
193
196
|
exports.takeScreenshot = takeScreenshot;
|
|
194
197
|
async function click(frame, element) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
await element.click();
|
|
198
|
+
const resolvedElement = isSelector(element) ? await findElement(frame, element) : element;
|
|
199
|
+
await (resolvedElement === null || resolvedElement === void 0 ? void 0 : resolvedElement.click());
|
|
198
200
|
}
|
|
199
201
|
exports.click = click;
|
|
200
202
|
async function hover(frame, element) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
await element.hover();
|
|
203
|
+
const resolvedElement = isSelector(element) ? await findElement(frame, element) : element;
|
|
204
|
+
await (resolvedElement === null || resolvedElement === void 0 ? void 0 : resolvedElement.hover());
|
|
204
205
|
}
|
|
205
206
|
exports.hover = hover;
|
|
206
207
|
async function scrollIntoView(frame, element, align = false) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
const resolvedElement = isSelector(element) ? await findElement(frame, element) : element;
|
|
209
|
+
await frame.evaluate(([element, align]) => element === null || element === void 0 ? void 0 : element.scrollIntoView(align), [
|
|
210
|
+
resolvedElement,
|
|
211
|
+
align,
|
|
212
|
+
]);
|
|
211
213
|
}
|
|
212
214
|
exports.scrollIntoView = scrollIntoView;
|
|
213
215
|
async function waitUntilDisplayed(frame, selector) {
|
|
@@ -223,6 +225,14 @@ const browserNames = {
|
|
|
223
225
|
safari: 'webkit',
|
|
224
226
|
firefox: 'firefox',
|
|
225
227
|
};
|
|
228
|
+
/*
|
|
229
|
+
* Spawn a browser with a given configuration (INTERNAL USE ONLY)
|
|
230
|
+
*
|
|
231
|
+
* NOTE:
|
|
232
|
+
* This function is intended for internal use only. As a result it relies on some dev dependencies.
|
|
233
|
+
* When wiring the spec-driver up to an SDK and calling this function, if you don't have the same dev deps
|
|
234
|
+
* installed in the SDK, then this function will error.
|
|
235
|
+
*/
|
|
226
236
|
async function build(env) {
|
|
227
237
|
const playwright = require('playwright');
|
|
228
238
|
const parseEnv = require('@applitools/test-utils/src/parse-env');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/spec-driver-playwright",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"playwright",
|
|
6
6
|
"chrome devtools protocol",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"types"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint '**/*.ts'",
|
|
39
|
-
"build": "ttsc",
|
|
38
|
+
"lint": "node ../../node_modules/.bin/eslint '**/*.ts'",
|
|
39
|
+
"build": "node ../../node_modules/.bin/ttsc --project ./tsconfig.build.json",
|
|
40
40
|
"test": "mocha ./test/**/*.spec.ts --no-timeouts --exit -r ts-node/register",
|
|
41
41
|
"test:sanity": "yarn test",
|
|
42
42
|
"setup": "yarn playwright:setup",
|
|
@@ -49,36 +49,18 @@
|
|
|
49
49
|
"version": "bongo version",
|
|
50
50
|
"postversion": "bongo postversion --skip-release-notification"
|
|
51
51
|
},
|
|
52
|
-
"husky": {
|
|
53
|
-
"hooks": {
|
|
54
|
-
"pre-push": "yarn bongo lint"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
52
|
"dependencies": {
|
|
58
|
-
"@applitools/driver": "1.11.
|
|
59
|
-
"@applitools/utils": "1.3.
|
|
53
|
+
"@applitools/driver": "1.11.31",
|
|
54
|
+
"@applitools/utils": "1.3.30"
|
|
60
55
|
},
|
|
61
56
|
"devDependencies": {
|
|
62
57
|
"@applitools/api-extractor": "^1.2.11",
|
|
63
|
-
"@applitools/bongo": "^2.2.
|
|
64
|
-
"@applitools/
|
|
65
|
-
"@applitools/test-utils": "1.5.8",
|
|
58
|
+
"@applitools/bongo": "^2.2.5",
|
|
59
|
+
"@applitools/test-utils": "1.5.12",
|
|
66
60
|
"@types/mocha": "^9.0.0",
|
|
67
61
|
"@types/node": "12",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
69
|
-
"@typescript-eslint/parser": "^5.27.0",
|
|
70
|
-
"eslint": "^8.16.0",
|
|
71
|
-
"eslint-config-prettier": "^8.5.0",
|
|
72
|
-
"eslint-plugin-mocha-no-only": "^1.1.1",
|
|
73
|
-
"eslint-plugin-node": "^11.1.0",
|
|
74
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
75
|
-
"husky": "^4.3.7",
|
|
76
62
|
"mocha": "^9.2.2",
|
|
77
|
-
"playwright": "^1.
|
|
78
|
-
"prettier": "^2.6.2",
|
|
79
|
-
"ts-node": "^10.8.0",
|
|
80
|
-
"ttypescript": "^1.5.13",
|
|
81
|
-
"typescript": "^4.8.4"
|
|
63
|
+
"playwright": "^1.29.2"
|
|
82
64
|
},
|
|
83
65
|
"peerDependencies": {
|
|
84
66
|
"playwright": ">=1.0.0"
|
package/types/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
declare const _default: import('@applitools/driver').SpecDriver<
|
|
1
|
+
declare const _default: import('@applitools/driver').SpecDriver<SpecType>;
|
|
2
2
|
export default _default;
|
|
3
3
|
export function isDriver(page: any): page is Driver;
|
|
4
4
|
export function isContext(frame: any): frame is Context;
|
|
5
5
|
export function isElement(element: any): element is Element<Node>;
|
|
6
6
|
export function isSelector(selector: any): selector is Selector;
|
|
7
|
-
export function transformSelector(selector:
|
|
8
|
-
export function untransformSelector(selector: Selector):
|
|
7
|
+
export function transformSelector(selector: import('@applitools/driver').CommonSelector<SpecType>): Selector;
|
|
8
|
+
export function untransformSelector(selector: Selector): import('@applitools/driver').CommonSelector<never>;
|
|
9
9
|
export function extractContext(page: Driver | Context): Context;
|
|
10
10
|
export function isStaleElementError(err: any): boolean;
|
|
11
11
|
export function executeScript(frame: Context, script: string | ((arg: any) => any), arg: any): Promise<any>;
|
|
12
12
|
export function mainContext(frame: Context): Promise<Context>;
|
|
13
13
|
export function parentContext(frame: Context): Promise<Context>;
|
|
14
14
|
export function childContext(_frame: Context, element: Element<Node>): Promise<Context>;
|
|
15
|
-
export function findElement(frame: Context, selector: Selector, parent?: Element<Node>): Promise<Element<
|
|
16
|
-
export function findElements(frame: Context, selector: Selector, parent?: Element<Node>): Promise<Array<Element<
|
|
15
|
+
export function findElement(frame: Context, selector: Selector, parent?: undefined | Element<Node>): Promise<null | Element<HTMLElement | SVGElement>>;
|
|
16
|
+
export function findElements(frame: Context, selector: Selector, parent?: undefined | Element<Node>): Promise<Array<Element<HTMLElement | SVGElement>>>;
|
|
17
17
|
export function setElementText(frame: Context, element: Selector | Element<Node>, text: string): Promise<void>;
|
|
18
18
|
export function getViewportSize(page: Driver): Promise<{ width: number; height: number; }>;
|
|
19
19
|
export function setViewportSize(page: Driver, size: { width: number; height: number; }): Promise<void>;
|
|
@@ -28,7 +28,8 @@ export function hover(frame: Context, element: Selector | Element<Node>): Promis
|
|
|
28
28
|
export function scrollIntoView(frame: Context, element: Selector | Element<Node>, align: boolean): Promise<void>;
|
|
29
29
|
export function waitUntilDisplayed(frame: Context, selector: Selector): Promise<void>;
|
|
30
30
|
export function build(env: any): Promise<[Driver, () => Promise<void>]>;
|
|
31
|
-
export type Driver = import('playwright').Page & { __applitoolsBrand?:
|
|
32
|
-
export type Context = import('playwright').Frame & { __applitoolsBrand?:
|
|
33
|
-
export type Element<T = Node> = import('playwright').ElementHandle<T> & { __applitoolsBrand?:
|
|
34
|
-
export type Selector = (string | import('playwright').Locator) & { __applitoolsBrand?:
|
|
31
|
+
export type Driver = import('playwright').Page & { __applitoolsBrand?: undefined; };
|
|
32
|
+
export type Context = import('playwright').Frame & { __applitoolsBrand?: undefined; };
|
|
33
|
+
export type Element<T = Node> = import('playwright').ElementHandle<T> & { __applitoolsBrand?: undefined; };
|
|
34
|
+
export type Selector = (string | import('playwright').Locator) & { __applitoolsBrand?: undefined; };
|
|
35
|
+
export type SpecType = { driver: Driver; context: Context; element: Element<Node>; selector: Selector; };
|