@applitools/spec-driver-selenium 1.3.2 → 1.3.5
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 +35 -4
- package/package.json +8 -10
- package/types/index.d.ts +1 -0
- package/CHANGELOG.md +0 -42
package/dist/spec-driver.js
CHANGED
|
@@ -30,7 +30,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
30
30
|
return t;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.build = exports.performAction = exports.getElementText = exports.getElementAttribute = exports.getElementRegion = exports.getOrientation = exports.getBarsHeight = 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.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;
|
|
33
|
+
exports.build = exports.performAction = exports.getElementText = exports.getElementAttribute = exports.getElementRegion = exports.getOrientation = exports.getBarsHeight = 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
34
|
const Selenium = __importStar(require("selenium-webdriver"));
|
|
35
35
|
const utils = __importStar(require("@applitools/utils"));
|
|
36
36
|
// #region HELPERS
|
|
@@ -39,9 +39,9 @@ function extractElementId(element) {
|
|
|
39
39
|
return isElement(element) ? element.getId() : element['shadow-6066-11e4-a52e-4f735466cecf'];
|
|
40
40
|
}
|
|
41
41
|
function transformShadowRoot(driver, shadowRoot) {
|
|
42
|
-
return
|
|
43
|
-
? shadowRoot
|
|
44
|
-
:
|
|
42
|
+
return utils.types.has(shadowRoot, 'shadow-6066-11e4-a52e-4f735466cecf')
|
|
43
|
+
? new Selenium.WebElement(driver, shadowRoot['shadow-6066-11e4-a52e-4f735466cecf'])
|
|
44
|
+
: shadowRoot;
|
|
45
45
|
}
|
|
46
46
|
// #endregion
|
|
47
47
|
// #region UTILITY
|
|
@@ -68,6 +68,7 @@ function transformDriver(driver) {
|
|
|
68
68
|
driver.getExecutor().defineCommand('setWindowPosition', 'POST', '/session/:sessionId/window/current/position');
|
|
69
69
|
driver.getExecutor().defineCommand('performTouch', 'POST', '/session/:sessionId/touch/perform');
|
|
70
70
|
driver.getExecutor().defineCommand('executeCdp', 'POST', '/session/:sessionId/chromium/send_command_and_get_result');
|
|
71
|
+
driver.getExecutor().defineCommand('setOrientation', 'POST', '/session/:sessionId/orientation/');
|
|
71
72
|
if (process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
|
|
72
73
|
driver.getExecutor().defineCommand('switchToParentFrame', 'POST', '/session/:sessionId/frame/parent');
|
|
73
74
|
}
|
|
@@ -150,6 +151,17 @@ async function findElements(driver, selector, parent) {
|
|
|
150
151
|
return root.findElements(selector);
|
|
151
152
|
}
|
|
152
153
|
exports.findElements = findElements;
|
|
154
|
+
async function waitForSelector(driver, selector, _parent, options) {
|
|
155
|
+
var _a;
|
|
156
|
+
if (((_a = options === null || options === void 0 ? void 0 : options.state) !== null && _a !== void 0 ? _a : 'exists') === 'exist') {
|
|
157
|
+
return driver.wait(Selenium.until.elementLocated(selector), options === null || options === void 0 ? void 0 : options.timeout);
|
|
158
|
+
}
|
|
159
|
+
else if ((options === null || options === void 0 ? void 0 : options.state) === 'visible') {
|
|
160
|
+
const element = await findElement(driver, selector);
|
|
161
|
+
return driver.wait(Selenium.until.elementIsVisible(element), options === null || options === void 0 ? void 0 : options.timeout);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.waitForSelector = waitForSelector;
|
|
153
165
|
async function getWindowSize(driver) {
|
|
154
166
|
try {
|
|
155
167
|
const rect = await driver.manage().window().getRect();
|
|
@@ -290,16 +302,32 @@ exports.waitUntilDisplayed = waitUntilDisplayed;
|
|
|
290
302
|
// #region MOBILE COMMANDS
|
|
291
303
|
async function getBarsHeight(driver) {
|
|
292
304
|
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
|
+
}
|
|
293
311
|
const getSystemBarsCommand = new Command('getSystemBars');
|
|
294
312
|
const { statusBar, navigationBar } = process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
|
|
295
313
|
? await driver.schedule(getSystemBarsCommand)
|
|
296
314
|
: await driver.execute(getSystemBarsCommand);
|
|
315
|
+
if (orientation.toLowerCase() === 'landscape') {
|
|
316
|
+
await setOrientation(driver, 'landscape');
|
|
317
|
+
}
|
|
297
318
|
return {
|
|
298
319
|
statusBarHeight: statusBar.visible ? statusBar.height : 0,
|
|
299
320
|
navigationBarHeight: navigationBar.visible ? navigationBar.height : 0,
|
|
300
321
|
};
|
|
301
322
|
}
|
|
302
323
|
exports.getBarsHeight = getBarsHeight;
|
|
324
|
+
async function setOrientation(driver, orientation) {
|
|
325
|
+
const { Command } = require('selenium-webdriver/lib/command');
|
|
326
|
+
const setOrientationCommand = new Command('setOrientation').setParameters({ orientation });
|
|
327
|
+
process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
|
|
328
|
+
? await driver.schedule(setOrientationCommand)
|
|
329
|
+
: await driver.execute(setOrientationCommand);
|
|
330
|
+
}
|
|
303
331
|
async function getOrientation(driver) {
|
|
304
332
|
const { Command } = require('selenium-webdriver/lib/command');
|
|
305
333
|
const getOrientationCommand = new Command('getOrientation');
|
|
@@ -373,6 +401,9 @@ async function build(env) {
|
|
|
373
401
|
if (appium && browser === 'chrome') {
|
|
374
402
|
desiredCapabilities['appium:chromeOptions'] = { w3c: false };
|
|
375
403
|
}
|
|
404
|
+
if (browser === 'chrome' && process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
|
|
405
|
+
desiredCapabilities['goog:chromeOptions'] = { w3c: false };
|
|
406
|
+
}
|
|
376
407
|
const builder = new Selenium.Builder().withCapabilities(desiredCapabilities);
|
|
377
408
|
if (url && !attach)
|
|
378
409
|
builder.usingServer(url.href);
|
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.5",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"selenium",
|
|
6
6
|
"selenium-webdriver",
|
|
@@ -41,14 +41,13 @@
|
|
|
41
41
|
"lint": "eslint '**/*.ts'",
|
|
42
42
|
"build": "ttsc",
|
|
43
43
|
"test": "mocha ./test/**/*.spec.ts --no-timeouts -r ts-node/register -r @applitools/test-utils/mocha-hooks/docker",
|
|
44
|
-
"setup": "yarn
|
|
45
|
-
"chromedriver:setup": "chromedriver --port=4444 --url-base=/wd/hub &",
|
|
44
|
+
"setup": "yarn docker:setup",
|
|
46
45
|
"docker:setup": "node ../scripts/scripts/generate-docker-compose-config.js && docker-compose up -d",
|
|
47
46
|
"docker:teardown": "docker-compose down",
|
|
48
47
|
"upgrade:framework": "if [ ! -z $APPLITOOLS_SELENIUM_MAJOR_VERSION ]; then packagejson=`cat package.json`; yarn upgrade --no-lockfile selenium-webdriver@$APPLITOOLS_SELENIUM_MAJOR_VERSION; echo \"$packagejson\" > package.json; fi",
|
|
49
48
|
"deps": "bongo deps",
|
|
50
49
|
"gh:test": "gh workflow run test.yml --ref $(git rev-parse --abbrev-ref HEAD) -f packages='spec-selenium spec-selenium@3' -f links='types utils test-utils'",
|
|
51
|
-
"gh:publish": "gh workflow run publish.yml --ref $(git rev-parse --abbrev-ref HEAD)
|
|
50
|
+
"gh:publish": "gh workflow run publish-spec-selenium.yml --ref $(git rev-parse --abbrev-ref HEAD)",
|
|
52
51
|
"preversion": "bongo preversion",
|
|
53
52
|
"version": "bongo version",
|
|
54
53
|
"postversion": "bongo postversion --skip-release-notification"
|
|
@@ -59,20 +58,19 @@
|
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
|
-
"@applitools/types": "1.0
|
|
63
|
-
"@applitools/utils": "1.2.
|
|
61
|
+
"@applitools/types": "1.3.0",
|
|
62
|
+
"@applitools/utils": "1.2.13"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
|
-
"@applitools/api-extractor": "^1.2.
|
|
65
|
+
"@applitools/api-extractor": "^1.2.7",
|
|
66
|
+
"@applitools/bongo": "2.0.1",
|
|
67
67
|
"@applitools/scripts": "1.1.0",
|
|
68
|
-
"@applitools/
|
|
69
|
-
"@applitools/test-utils": "1.0.10",
|
|
68
|
+
"@applitools/test-utils": "1.3.0",
|
|
70
69
|
"@types/mocha": "^9.0.0",
|
|
71
70
|
"@types/node": "^16.10.2",
|
|
72
71
|
"@types/selenium-webdriver": "^4.0.15",
|
|
73
72
|
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
|
74
73
|
"@typescript-eslint/parser": "^4.15.1",
|
|
75
|
-
"chromedriver": "^96",
|
|
76
74
|
"eslint": "^7.9.0",
|
|
77
75
|
"eslint-config-prettier": "^7.2.0",
|
|
78
76
|
"eslint-plugin-mocha-no-only": "^1.1.1",
|
package/types/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export function parentContext(driver: Driver): Promise<Driver>;
|
|
|
13
13
|
export function childContext(driver: Driver, element: Element): Promise<Driver>;
|
|
14
14
|
export function findElement(driver: Driver, selector: Selector, parent?: Element): Promise<Element>;
|
|
15
15
|
export function findElements(driver: Driver, selector: Selector, parent?: Element): Promise<Array<Element>>;
|
|
16
|
+
export function waitForSelector(driver: Driver, selector: Selector, _parent?: Element, options?: import('@applitools/types').WaitOptions): Promise<Element>;
|
|
16
17
|
export function getWindowSize(driver: Driver): Promise<import('@applitools/types').Size>;
|
|
17
18
|
export function setWindowSize(driver: Driver, size: import('@applitools/types').Size): Promise<void>;
|
|
18
19
|
export function getCookies(driver: Driver, context?: boolean): Promise<Array<import('@applitools/types').Cookie>>;
|
package/CHANGELOG.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
## Unreleased
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## 1.3.2 - 2022/1/12
|
|
7
|
-
|
|
8
|
-
- no changes
|
|
9
|
-
|
|
10
|
-
## 1.3.1 - 2022/1/12
|
|
11
|
-
|
|
12
|
-
- use chromedriver instead of selenium docker container for testing
|
|
13
|
-
- fix tests for selenium 3
|
|
14
|
-
- fix `getCapabilities` for selenium 3
|
|
15
|
-
- updated to @applitools/types@1.0.23 (from 1.0.20)
|
|
16
|
-
- updated to @applitools/utils@1.2.11 (from 1.2.4)
|
|
17
|
-
|
|
18
|
-
## 1.3.0 - 2021/11/17
|
|
19
|
-
|
|
20
|
-
- implement `getCapabilities` and `getBarsHeight` instead of `getDriverInfo`
|
|
21
|
-
- updated to @applitools/types@1.0.20 (from 1.0.19)
|
|
22
|
-
|
|
23
|
-
## 1.2.0 - 2021/11/10
|
|
24
|
-
|
|
25
|
-
- updated to @applitools/types@1.0.19 (from 1.0.15)
|
|
26
|
-
- updated to @applitools/utils@1.2.4 (from 1.2.3)
|
|
27
|
-
|
|
28
|
-
## 1.1.1 - 2021/10/20
|
|
29
|
-
|
|
30
|
-
- install prettier
|
|
31
|
-
|
|
32
|
-
## 1.1.0 - 2021/10/12
|
|
33
|
-
|
|
34
|
-
- change default selenium version
|
|
35
|
-
|
|
36
|
-
## 1.0.2 - 2021/10/12
|
|
37
|
-
|
|
38
|
-
- handle non-w3c appium driver
|
|
39
|
-
|
|
40
|
-
## 1.0.1 - 2021/10/12
|
|
41
|
-
|
|
42
|
-
- spec driver implementation for selenium framework
|