@applitools/spec-driver-selenium 1.3.10 → 1.3.13
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 +2 -1
- package/dist/spec-driver.js +28 -10
- package/package.json +8 -7
- package/types/index.d.ts +17 -4
package/dist/index.js
CHANGED
package/dist/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.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;
|
|
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.untransformSelector = exports.transformSelector = exports.transformDriver = exports.isSelector = exports.isElement = exports.isDriver = void 0;
|
|
27
27
|
const Selenium = __importStar(require("selenium-webdriver"));
|
|
28
28
|
const utils = __importStar(require("@applitools/utils"));
|
|
29
29
|
// #region HELPERS
|
|
@@ -36,6 +36,9 @@ function transformShadowRoot(driver, shadowRoot) {
|
|
|
36
36
|
? new Selenium.WebElement(driver, shadowRoot['shadow-6066-11e4-a52e-4f735466cecf'])
|
|
37
37
|
: shadowRoot;
|
|
38
38
|
}
|
|
39
|
+
function isByHashSelector(selector) {
|
|
40
|
+
return byHash.includes(Object.keys(selector)[0]);
|
|
41
|
+
}
|
|
39
42
|
// #endregion
|
|
40
43
|
// #region UTILITY
|
|
41
44
|
function isDriver(driver) {
|
|
@@ -49,7 +52,10 @@ exports.isElement = isElement;
|
|
|
49
52
|
function isSelector(selector) {
|
|
50
53
|
if (!selector)
|
|
51
54
|
return false;
|
|
52
|
-
return utils.types.has(selector, ['using', 'value']) ||
|
|
55
|
+
return (utils.types.has(selector, ['using', 'value']) ||
|
|
56
|
+
isByHashSelector(selector) ||
|
|
57
|
+
utils.types.isFunction(selector) ||
|
|
58
|
+
utils.types.instanceOf(selector, 'RelativeBy'));
|
|
53
59
|
}
|
|
54
60
|
exports.isSelector = isSelector;
|
|
55
61
|
function transformDriver(driver) {
|
|
@@ -85,6 +91,22 @@ function transformSelector(selector) {
|
|
|
85
91
|
return selector;
|
|
86
92
|
}
|
|
87
93
|
exports.transformSelector = transformSelector;
|
|
94
|
+
function untransformSelector(selector) {
|
|
95
|
+
if (utils.types.instanceOf(selector, 'RelativeBy') || utils.types.isFunction(selector)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
else if (isByHashSelector(selector)) {
|
|
99
|
+
const [[how, what]] = Object.entries(selector);
|
|
100
|
+
if (how === 'js')
|
|
101
|
+
return null;
|
|
102
|
+
selector = Selenium.By[how](what);
|
|
103
|
+
}
|
|
104
|
+
if (utils.types.has(selector, ['using', 'value'])) {
|
|
105
|
+
return { type: selector.using === 'css selector' ? 'css' : selector.using, selector: selector.value };
|
|
106
|
+
}
|
|
107
|
+
return selector;
|
|
108
|
+
}
|
|
109
|
+
exports.untransformSelector = untransformSelector;
|
|
88
110
|
function isStaleElementError(error) {
|
|
89
111
|
if (!error)
|
|
90
112
|
return false;
|
|
@@ -296,14 +318,9 @@ exports.waitUntilDisplayed = waitUntilDisplayed;
|
|
|
296
318
|
async function getBarsSize(driver) {
|
|
297
319
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
298
320
|
const getSystemBarsCommand = new Command('getSystemBars');
|
|
299
|
-
|
|
321
|
+
return process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
|
|
300
322
|
? await driver.schedule(getSystemBarsCommand)
|
|
301
323
|
: await driver.execute(getSystemBarsCommand);
|
|
302
|
-
return {
|
|
303
|
-
statusBarHeight: statusBar.visible ? statusBar.height : 0,
|
|
304
|
-
navigationBarHeight: navigationBar.visible ? navigationBar.height : 0,
|
|
305
|
-
navigationBarWidth: navigationBar.visible ? navigationBar.width : 0,
|
|
306
|
-
};
|
|
307
324
|
}
|
|
308
325
|
exports.getBarsSize = getBarsSize;
|
|
309
326
|
async function setOrientation(driver, orientation) {
|
|
@@ -361,8 +378,9 @@ const browserOptionsNames = {
|
|
|
361
378
|
chrome: 'goog:chromeOptions',
|
|
362
379
|
firefox: 'moz:firefoxOptions',
|
|
363
380
|
};
|
|
364
|
-
async function build(env) {
|
|
381
|
+
async function build({ selenium, ...env }) {
|
|
365
382
|
var _a;
|
|
383
|
+
const { Builder } = (selenium !== null && selenium !== void 0 ? selenium : require('selenium-webdriver'));
|
|
366
384
|
const parseEnv = require('@applitools/test-utils/src/parse-env');
|
|
367
385
|
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
386
|
const desiredCapabilities = { ...capabilities };
|
|
@@ -387,7 +405,7 @@ async function build(env) {
|
|
|
387
405
|
if (browser === 'chrome' && process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
|
|
388
406
|
desiredCapabilities['goog:chromeOptions'] = { w3c: false };
|
|
389
407
|
}
|
|
390
|
-
const builder = new
|
|
408
|
+
const builder = new Builder().withCapabilities(desiredCapabilities);
|
|
391
409
|
if (url && !attach)
|
|
392
410
|
builder.usingServer(url.href);
|
|
393
411
|
if (proxy) {
|
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.13",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"selenium",
|
|
6
6
|
"selenium-webdriver",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
21
|
-
"directory": "packages/spec-driver-selenium"
|
|
21
|
+
"directory": "js/packages/spec-driver-selenium"
|
|
22
22
|
},
|
|
23
23
|
"license": "SEE LICENSE IN LICENSE",
|
|
24
24
|
"author": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"lint": "eslint '**/*.ts'",
|
|
45
45
|
"build": "ttsc",
|
|
46
46
|
"test": "mocha ./test/**/*.spec.ts --no-timeouts -r ts-node/register -r @applitools/test-utils/mocha-hooks/docker",
|
|
47
|
+
"test:sanity": "yarn test",
|
|
47
48
|
"setup": "yarn docker:setup",
|
|
48
49
|
"docker:setup": "node ../scripts/scripts/generate-docker-compose-config.js && docker-compose up -d",
|
|
49
50
|
"docker:teardown": "docker-compose down",
|
|
@@ -61,14 +62,14 @@
|
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@applitools/types": "1.5.
|
|
65
|
-
"@applitools/utils": "1.3.
|
|
65
|
+
"@applitools/types": "1.5.6",
|
|
66
|
+
"@applitools/utils": "1.3.10"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@applitools/api-extractor": "^1.2.
|
|
69
|
-
"@applitools/bongo": "2.1.
|
|
69
|
+
"@applitools/api-extractor": "^1.2.9",
|
|
70
|
+
"@applitools/bongo": "2.1.6",
|
|
70
71
|
"@applitools/scripts": "1.1.0",
|
|
71
|
-
"@applitools/test-utils": "1.3.
|
|
72
|
+
"@applitools/test-utils": "1.3.4",
|
|
72
73
|
"@types/mocha": "^9.1.1",
|
|
73
74
|
"@types/node": "12",
|
|
74
75
|
"@types/selenium-webdriver": "^4.1.1",
|
package/types/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export function isDriver(driver: any): driver is Driver;
|
|
|
4
4
|
export function isElement(element: any): element is Element;
|
|
5
5
|
export function isSelector(selector: any): selector is Selector;
|
|
6
6
|
export function transformDriver(driver: Driver): Driver;
|
|
7
|
-
export function transformSelector(selector:
|
|
7
|
+
export function transformSelector(selector: string | { selector: string | Selector; type?: string; }): Selector;
|
|
8
|
+
export function untransformSelector(selector: Selector): string | { selector: string; type?: string; };
|
|
8
9
|
export function isStaleElementError(error: any): boolean;
|
|
9
10
|
export function isEqualElements(_driver: Driver, element1: Element, element2: Element): Promise<boolean>;
|
|
10
11
|
export function executeScript(driver: Driver, script: string | ((arg: any) => any), arg: any): Promise<any>;
|
|
@@ -28,14 +29,26 @@ export function hover(driver: Driver, element: Element | Selector): Promise<void
|
|
|
28
29
|
export function type(driver: Driver, element: Element | Selector, keys: string): Promise<void>;
|
|
29
30
|
export function scrollIntoView(driver: Driver, element: Element | Selector, align: boolean): Promise<void>;
|
|
30
31
|
export function waitUntilDisplayed(driver: Driver, selector: Selector, timeout: number): Promise<void>;
|
|
31
|
-
export function getBarsSize(driver: Driver): Promise<{
|
|
32
|
+
export function getBarsSize(driver: Driver): Promise<{ statusBar: {
|
|
33
|
+
visible: boolean;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
height: number;
|
|
37
|
+
width: number;
|
|
38
|
+
}; navigationBar: {
|
|
39
|
+
visible: boolean;
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
height: number;
|
|
43
|
+
width: number;
|
|
44
|
+
}; }>;
|
|
32
45
|
export function setOrientation(driver: Driver, orientation: import('@applitools/types').ScreenOrientation): Promise<void>;
|
|
33
46
|
export function getOrientation(driver: Driver): Promise<"portrait" | "landscape">;
|
|
34
47
|
export function getElementRegion(_driver: Driver, element: Element): Promise<import('@applitools/types').Region>;
|
|
35
48
|
export function getElementAttribute(_driver: Driver, element: Element, attr: string): Promise<string>;
|
|
36
49
|
export function getElementText(_driver: Driver, element: Element): Promise<string>;
|
|
37
50
|
export function performAction(driver: Driver, steps: Array<any>): Promise<void>;
|
|
38
|
-
export function build(
|
|
51
|
+
export function build(__0: any): Promise<[Driver, () => Promise<void>]>;
|
|
39
52
|
export type Driver = import('selenium-webdriver').WebDriver & { __applitoolsBrand?: never; };
|
|
40
53
|
export type Element = import('selenium-webdriver').WebElement & { __applitoolsBrand?: never; };
|
|
41
|
-
export type Selector = (import('selenium-webdriver').
|
|
54
|
+
export type Selector = (import('selenium-webdriver').By | import('selenium-webdriver').RelativeBy | import('selenium-webdriver').ByHash | { using: string; value: string; } | ((webdriver: import('selenium-webdriver').WebDriver) => Promise<any>)) & { __applitoolsBrand?: never; };
|