@applitools/spec-driver-selenium 1.3.5 → 1.3.8
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/index.js +6 -2
- package/dist/spec-driver.js +18 -35
- package/package.json +27 -24
- package/types/index.d.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -29,7 +33,7 @@ if (!process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION) {
|
|
|
29
33
|
const [major] = version.split('.', 1);
|
|
30
34
|
process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION = major;
|
|
31
35
|
}
|
|
32
|
-
catch
|
|
36
|
+
catch {
|
|
33
37
|
// NOTE: ignore error
|
|
34
38
|
}
|
|
35
39
|
}
|
package/dist/spec-driver.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -18,19 +22,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
22
|
-
var t = {};
|
|
23
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
24
|
-
t[p] = s[p];
|
|
25
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
26
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
27
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28
|
-
t[p[i]] = s[p[i]];
|
|
29
|
-
}
|
|
30
|
-
return t;
|
|
31
|
-
};
|
|
32
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.build = exports.performAction = exports.getElementText = exports.getElementAttribute = exports.getElementRegion = exports.getOrientation = exports.
|
|
26
|
+
exports.build = exports.performAction = exports.getElementText = exports.getElementAttribute = exports.getElementRegion = exports.getOrientation = exports.setOrientation = exports.getBarsSize = exports.waitUntilDisplayed = exports.scrollIntoView = exports.type = exports.hover = exports.click = exports.takeScreenshot = exports.visit = exports.getUrl = exports.getTitle = exports.getCapabilities = exports.getDriverInfo = exports.getCookies = exports.setWindowSize = exports.getWindowSize = exports.waitForSelector = exports.findElements = exports.findElement = exports.childContext = exports.parentContext = exports.mainContext = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.transformSelector = exports.transformDriver = exports.isSelector = exports.isElement = exports.isDriver = void 0;
|
|
34
27
|
const Selenium = __importStar(require("selenium-webdriver"));
|
|
35
28
|
const utils = __importStar(require("@applitools/utils"));
|
|
36
29
|
// #region HELPERS
|
|
@@ -167,7 +160,7 @@ async function getWindowSize(driver) {
|
|
|
167
160
|
const rect = await driver.manage().window().getRect();
|
|
168
161
|
return { width: rect.width, height: rect.height };
|
|
169
162
|
}
|
|
170
|
-
catch
|
|
163
|
+
catch {
|
|
171
164
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
172
165
|
const getWindowSizeCommand = new Command('getWindowSize');
|
|
173
166
|
const size = driver.manage().window().getSize
|
|
@@ -181,14 +174,14 @@ async function setWindowSize(driver, size) {
|
|
|
181
174
|
try {
|
|
182
175
|
await driver.manage().window().setRect({ x: 0, y: 0, width: size.width, height: size.height });
|
|
183
176
|
}
|
|
184
|
-
catch
|
|
177
|
+
catch {
|
|
185
178
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
186
179
|
const setWindowPositionCommand = new Command('setWindowPosition').setParameters({ x: 0, y: 0 });
|
|
187
180
|
if (driver.manage().window().setPosition)
|
|
188
181
|
await driver.manage().window().setPosition(0, 0);
|
|
189
182
|
else
|
|
190
183
|
await driver.execute(setWindowPositionCommand);
|
|
191
|
-
const setWindowSizeCommand = new Command('setWindowSize').setParameters(
|
|
184
|
+
const setWindowSizeCommand = new Command('setWindowSize').setParameters({ ...size });
|
|
192
185
|
if (driver.manage().window().setSize)
|
|
193
186
|
await driver.manage().window().setSize(size.width, size.height);
|
|
194
187
|
else
|
|
@@ -215,7 +208,7 @@ async function getCookies(driver, context) {
|
|
|
215
208
|
cookies = response.cookies;
|
|
216
209
|
}
|
|
217
210
|
return cookies.map((cookie) => {
|
|
218
|
-
const copy =
|
|
211
|
+
const copy = { ...cookie, expiry: cookie.expires };
|
|
219
212
|
delete copy.expires;
|
|
220
213
|
delete copy.size;
|
|
221
214
|
delete copy.priority;
|
|
@@ -240,7 +233,7 @@ async function getCapabilities(driver) {
|
|
|
240
233
|
? await driver.schedule(getSessionDetailsCommand)
|
|
241
234
|
: await driver.execute(getSessionDetailsCommand);
|
|
242
235
|
}
|
|
243
|
-
catch
|
|
236
|
+
catch {
|
|
244
237
|
const capabilities = await driver.getCapabilities();
|
|
245
238
|
return Array.from(capabilities.keys()).reduce((obj, key) => Object.assign(obj, { key: capabilities.get(key) }), {});
|
|
246
239
|
}
|
|
@@ -300,27 +293,19 @@ async function waitUntilDisplayed(driver, selector, timeout) {
|
|
|
300
293
|
exports.waitUntilDisplayed = waitUntilDisplayed;
|
|
301
294
|
// #endregion
|
|
302
295
|
// #region MOBILE COMMANDS
|
|
303
|
-
async function
|
|
296
|
+
async function getBarsSize(driver) {
|
|
304
297
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
305
|
-
const orientation = await getOrientation(driver);
|
|
306
|
-
// when calling getSystemBars when orientation is landscape it seems that appium is buggy and returns the wrong dimensions
|
|
307
|
-
// therefore, we set the orientation to portrait to get the correct systemBars dimensions and we flip back to landscape
|
|
308
|
-
if (orientation.toLowerCase() === 'landscape') {
|
|
309
|
-
await setOrientation(driver, 'portrait');
|
|
310
|
-
}
|
|
311
298
|
const getSystemBarsCommand = new Command('getSystemBars');
|
|
312
299
|
const { statusBar, navigationBar } = process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
|
|
313
300
|
? await driver.schedule(getSystemBarsCommand)
|
|
314
301
|
: await driver.execute(getSystemBarsCommand);
|
|
315
|
-
if (orientation.toLowerCase() === 'landscape') {
|
|
316
|
-
await setOrientation(driver, 'landscape');
|
|
317
|
-
}
|
|
318
302
|
return {
|
|
319
303
|
statusBarHeight: statusBar.visible ? statusBar.height : 0,
|
|
320
304
|
navigationBarHeight: navigationBar.visible ? navigationBar.height : 0,
|
|
305
|
+
navigationBarWidth: navigationBar.visible ? navigationBar.width : 0,
|
|
321
306
|
};
|
|
322
307
|
}
|
|
323
|
-
exports.
|
|
308
|
+
exports.getBarsSize = getBarsSize;
|
|
324
309
|
async function setOrientation(driver, orientation) {
|
|
325
310
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
326
311
|
const setOrientationCommand = new Command('setOrientation').setParameters({ orientation });
|
|
@@ -328,6 +313,7 @@ async function setOrientation(driver, orientation) {
|
|
|
328
313
|
? await driver.schedule(setOrientationCommand)
|
|
329
314
|
: await driver.execute(setOrientationCommand);
|
|
330
315
|
}
|
|
316
|
+
exports.setOrientation = setOrientation;
|
|
331
317
|
async function getOrientation(driver) {
|
|
332
318
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
333
319
|
const getOrientationCommand = new Command('getOrientation');
|
|
@@ -359,10 +345,7 @@ exports.getElementText = getElementText;
|
|
|
359
345
|
async function performAction(driver, steps) {
|
|
360
346
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
361
347
|
const performTouchCommand = new Command('performTouch').setParameters({
|
|
362
|
-
actions: steps.map((
|
|
363
|
-
var { action } = _a, options = __rest(_a, ["action"]);
|
|
364
|
-
return ({ action, options });
|
|
365
|
-
}),
|
|
348
|
+
actions: steps.map(({ action, ...options }) => ({ action, options })),
|
|
366
349
|
});
|
|
367
350
|
if (process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
|
|
368
351
|
await driver.schedule(performTouchCommand);
|
|
@@ -381,8 +364,8 @@ const browserOptionsNames = {
|
|
|
381
364
|
async function build(env) {
|
|
382
365
|
var _a;
|
|
383
366
|
const parseEnv = require('@applitools/test-utils/src/parse-env');
|
|
384
|
-
const { browser, capabilities, url, attach, proxy, configurable = true, appium = false, args = [], headless, } = parseEnv(
|
|
385
|
-
const desiredCapabilities =
|
|
367
|
+
const { browser, capabilities, url, attach, proxy, configurable = true, appium = false, args = [], headless, } = parseEnv({ ...env, legacy: (_a = env.legacy) !== null && _a !== void 0 ? _a : process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3' });
|
|
368
|
+
const desiredCapabilities = { ...capabilities };
|
|
386
369
|
if (configurable) {
|
|
387
370
|
const browserOptionsName = browserOptionsNames[browser || desiredCapabilities.browserName];
|
|
388
371
|
if (browserOptionsName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/spec-driver-selenium",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"selenium",
|
|
6
6
|
"selenium-webdriver",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"name": "Applitools Team",
|
|
26
26
|
"email": "team@applitools.com"
|
|
27
27
|
},
|
|
28
|
-
"main": "./dist/index.js",
|
|
29
|
-
"types": "./types/index.d.ts",
|
|
30
28
|
"exports": {
|
|
31
29
|
".": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
30
|
+
"types": "./types/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
34
32
|
}
|
|
35
33
|
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"types": "./types/index.d.ts",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist",
|
|
38
38
|
"types"
|
|
@@ -58,33 +58,36 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@applitools/types": "1.
|
|
62
|
-
"@applitools/utils": "1.
|
|
61
|
+
"@applitools/types": "1.4.7",
|
|
62
|
+
"@applitools/utils": "1.3.6"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@applitools/api-extractor": "^1.2.
|
|
66
|
-
"@applitools/bongo": "2.
|
|
65
|
+
"@applitools/api-extractor": "^1.2.8",
|
|
66
|
+
"@applitools/bongo": "2.1.4",
|
|
67
67
|
"@applitools/scripts": "1.1.0",
|
|
68
|
-
"@applitools/test-utils": "1.3.
|
|
69
|
-
"@types/mocha": "^9.
|
|
70
|
-
"@types/node": "
|
|
71
|
-
"@types/selenium-webdriver": "^4.
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
73
|
-
"@typescript-eslint/parser": "^
|
|
74
|
-
"eslint": "^
|
|
75
|
-
"eslint-config-prettier": "^
|
|
68
|
+
"@applitools/test-utils": "1.3.2",
|
|
69
|
+
"@types/mocha": "^9.1.1",
|
|
70
|
+
"@types/node": "12",
|
|
71
|
+
"@types/selenium-webdriver": "^4.1.1",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
73
|
+
"@typescript-eslint/parser": "^5.27.0",
|
|
74
|
+
"eslint": "^8.16.0",
|
|
75
|
+
"eslint-config-prettier": "^8.5.0",
|
|
76
76
|
"eslint-plugin-mocha-no-only": "^1.1.1",
|
|
77
77
|
"eslint-plugin-node": "^11.1.0",
|
|
78
|
-
"eslint-plugin-prettier": "^
|
|
78
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
79
79
|
"husky": "^4.3.7",
|
|
80
|
-
"mocha": "^9.
|
|
81
|
-
"prettier": "^2.
|
|
82
|
-
"selenium-webdriver": "^4.
|
|
83
|
-
"ts-node": "^10.
|
|
84
|
-
"ttypescript": "^1.5.
|
|
85
|
-
"typescript": "^4.
|
|
80
|
+
"mocha": "^9.2.2",
|
|
81
|
+
"prettier": "^2.6.2",
|
|
82
|
+
"selenium-webdriver": "^4.2.0",
|
|
83
|
+
"ts-node": "^10.8.0",
|
|
84
|
+
"ttypescript": "^1.5.13",
|
|
85
|
+
"typescript": "^4.7.2"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"selenium-webdriver": ">=3.6.0"
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=12.13.0"
|
|
89
92
|
}
|
|
90
93
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -28,7 +28,8 @@ export function hover(driver: Driver, element: Element | Selector): Promise<void
|
|
|
28
28
|
export function type(driver: Driver, element: Element | Selector, keys: string): Promise<void>;
|
|
29
29
|
export function scrollIntoView(driver: Driver, element: Element | Selector, align: boolean): Promise<void>;
|
|
30
30
|
export function waitUntilDisplayed(driver: Driver, selector: Selector, timeout: number): Promise<void>;
|
|
31
|
-
export function
|
|
31
|
+
export function getBarsSize(driver: Driver): Promise<{ statusBarHeight: number; navigationBarHeight: number; navigationBarWidth: number; }>;
|
|
32
|
+
export function setOrientation(driver: Driver, orientation: import('@applitools/types').ScreenOrientation): Promise<void>;
|
|
32
33
|
export function getOrientation(driver: Driver): Promise<"portrait" | "landscape">;
|
|
33
34
|
export function getElementRegion(_driver: Driver, element: Element): Promise<import('@applitools/types').Region>;
|
|
34
35
|
export function getElementAttribute(_driver: Driver, element: Element, attr: string): Promise<string>;
|