@applitools/spec-driver-selenium 1.3.3 → 1.3.6

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.
@@ -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.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
34
  const Selenium = __importStar(require("selenium-webdriver"));
35
35
  const utils = __importStar(require("@applitools/utils"));
36
36
  // #region HELPERS
@@ -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();
@@ -288,7 +300,7 @@ async function waitUntilDisplayed(driver, selector, timeout) {
288
300
  exports.waitUntilDisplayed = waitUntilDisplayed;
289
301
  // #endregion
290
302
  // #region MOBILE COMMANDS
291
- async function getBarsHeight(driver) {
303
+ async function getBarsSize(driver) {
292
304
  const { Command } = require('selenium-webdriver/lib/command');
293
305
  const getSystemBarsCommand = new Command('getSystemBars');
294
306
  const { statusBar, navigationBar } = process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
@@ -297,9 +309,18 @@ async function getBarsHeight(driver) {
297
309
  return {
298
310
  statusBarHeight: statusBar.visible ? statusBar.height : 0,
299
311
  navigationBarHeight: navigationBar.visible ? navigationBar.height : 0,
312
+ navigationBarWidth: navigationBar.visible ? navigationBar.width : 0,
300
313
  };
301
314
  }
302
- exports.getBarsHeight = getBarsHeight;
315
+ exports.getBarsSize = getBarsSize;
316
+ async function setOrientation(driver, orientation) {
317
+ const { Command } = require('selenium-webdriver/lib/command');
318
+ const setOrientationCommand = new Command('setOrientation').setParameters({ orientation });
319
+ process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
320
+ ? await driver.schedule(setOrientationCommand)
321
+ : await driver.execute(setOrientationCommand);
322
+ }
323
+ exports.setOrientation = setOrientation;
303
324
  async function getOrientation(driver) {
304
325
  const { Command } = require('selenium-webdriver/lib/command');
305
326
  const getOrientationCommand = new Command('getOrientation');
@@ -373,6 +394,9 @@ async function build(env) {
373
394
  if (appium && browser === 'chrome') {
374
395
  desiredCapabilities['appium:chromeOptions'] = { w3c: false };
375
396
  }
397
+ if (browser === 'chrome' && process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
398
+ desiredCapabilities['goog:chromeOptions'] = { w3c: false };
399
+ }
376
400
  const builder = new Selenium.Builder().withCapabilities(desiredCapabilities);
377
401
  if (url && !attach)
378
402
  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",
3
+ "version": "1.3.6",
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 chromedriver:setup",
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) -f packages='spec-selenium'",
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.23",
63
- "@applitools/utils": "1.2.11"
61
+ "@applitools/types": "1.3.2",
62
+ "@applitools/utils": "1.2.14"
64
63
  },
65
64
  "devDependencies": {
66
- "@applitools/api-extractor": "^1.2.6",
65
+ "@applitools/api-extractor": "^1.2.7",
66
+ "@applitools/bongo": "2.0.3",
67
67
  "@applitools/scripts": "1.1.0",
68
- "@applitools/sdk-release-kit": "0.13.10",
69
- "@applitools/test-utils": "1.0.10",
68
+ "@applitools/test-utils": "1.3.1",
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>>;
@@ -27,7 +28,8 @@ export function hover(driver: Driver, element: Element | Selector): Promise<void
27
28
  export function type(driver: Driver, element: Element | Selector, keys: string): Promise<void>;
28
29
  export function scrollIntoView(driver: Driver, element: Element | Selector, align: boolean): Promise<void>;
29
30
  export function waitUntilDisplayed(driver: Driver, selector: Selector, timeout: number): Promise<void>;
30
- export function getBarsHeight(driver: Driver): Promise<{ statusBarHeight: number; navigationBarHeight: number; }>;
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>;
31
33
  export function getOrientation(driver: Driver): Promise<"portrait" | "landscape">;
32
34
  export function getElementRegion(_driver: Driver, element: Element): Promise<import('@applitools/types').Region>;
33
35
  export function getElementAttribute(_driver: Driver, element: Element, attr: string): Promise<string>;
package/CHANGELOG.md DELETED
@@ -1,46 +0,0 @@
1
- # Change Log
2
-
3
- ## Unreleased
4
-
5
-
6
- ## 1.3.3 - 2022/1/12
7
-
8
- - add support of selenium 4 `ShadowRoot` objects
9
-
10
- ## 1.3.2 - 2022/1/12
11
-
12
- - no changes
13
-
14
- ## 1.3.1 - 2022/1/12
15
-
16
- - use chromedriver instead of selenium docker container for testing
17
- - fix tests for selenium 3
18
- - fix `getCapabilities` for selenium 3
19
- - updated to @applitools/types@1.0.23 (from 1.0.20)
20
- - updated to @applitools/utils@1.2.11 (from 1.2.4)
21
-
22
- ## 1.3.0 - 2021/11/17
23
-
24
- - implement `getCapabilities` and `getBarsHeight` instead of `getDriverInfo`
25
- - updated to @applitools/types@1.0.20 (from 1.0.19)
26
-
27
- ## 1.2.0 - 2021/11/10
28
-
29
- - updated to @applitools/types@1.0.19 (from 1.0.15)
30
- - updated to @applitools/utils@1.2.4 (from 1.2.3)
31
-
32
- ## 1.1.1 - 2021/10/20
33
-
34
- - install prettier
35
-
36
- ## 1.1.0 - 2021/10/12
37
-
38
- - change default selenium version
39
-
40
- ## 1.0.2 - 2021/10/12
41
-
42
- - handle non-w3c appium driver
43
-
44
- ## 1.0.1 - 2021/10/12
45
-
46
- - spec driver implementation for selenium framework