@applitools/spec-driver-selenium 1.3.4 → 1.3.7

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 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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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 (_a) {
36
+ catch {
33
37
  // NOTE: ignore error
34
38
  }
35
39
  }
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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.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;
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
@@ -68,6 +61,7 @@ function transformDriver(driver) {
68
61
  driver.getExecutor().defineCommand('setWindowPosition', 'POST', '/session/:sessionId/window/current/position');
69
62
  driver.getExecutor().defineCommand('performTouch', 'POST', '/session/:sessionId/touch/perform');
70
63
  driver.getExecutor().defineCommand('executeCdp', 'POST', '/session/:sessionId/chromium/send_command_and_get_result');
64
+ driver.getExecutor().defineCommand('setOrientation', 'POST', '/session/:sessionId/orientation/');
71
65
  if (process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
72
66
  driver.getExecutor().defineCommand('switchToParentFrame', 'POST', '/session/:sessionId/frame/parent');
73
67
  }
@@ -166,7 +160,7 @@ async function getWindowSize(driver) {
166
160
  const rect = await driver.manage().window().getRect();
167
161
  return { width: rect.width, height: rect.height };
168
162
  }
169
- catch (_a) {
163
+ catch {
170
164
  const { Command } = require('selenium-webdriver/lib/command');
171
165
  const getWindowSizeCommand = new Command('getWindowSize');
172
166
  const size = driver.manage().window().getSize
@@ -180,14 +174,14 @@ async function setWindowSize(driver, size) {
180
174
  try {
181
175
  await driver.manage().window().setRect({ x: 0, y: 0, width: size.width, height: size.height });
182
176
  }
183
- catch (_a) {
177
+ catch {
184
178
  const { Command } = require('selenium-webdriver/lib/command');
185
179
  const setWindowPositionCommand = new Command('setWindowPosition').setParameters({ x: 0, y: 0 });
186
180
  if (driver.manage().window().setPosition)
187
181
  await driver.manage().window().setPosition(0, 0);
188
182
  else
189
183
  await driver.execute(setWindowPositionCommand);
190
- const setWindowSizeCommand = new Command('setWindowSize').setParameters(Object.assign({}, size));
184
+ const setWindowSizeCommand = new Command('setWindowSize').setParameters({ ...size });
191
185
  if (driver.manage().window().setSize)
192
186
  await driver.manage().window().setSize(size.width, size.height);
193
187
  else
@@ -214,7 +208,7 @@ async function getCookies(driver, context) {
214
208
  cookies = response.cookies;
215
209
  }
216
210
  return cookies.map((cookie) => {
217
- const copy = Object.assign(Object.assign({}, cookie), { expiry: cookie.expires });
211
+ const copy = { ...cookie, expiry: cookie.expires };
218
212
  delete copy.expires;
219
213
  delete copy.size;
220
214
  delete copy.priority;
@@ -239,7 +233,7 @@ async function getCapabilities(driver) {
239
233
  ? await driver.schedule(getSessionDetailsCommand)
240
234
  : await driver.execute(getSessionDetailsCommand);
241
235
  }
242
- catch (_a) {
236
+ catch {
243
237
  const capabilities = await driver.getCapabilities();
244
238
  return Array.from(capabilities.keys()).reduce((obj, key) => Object.assign(obj, { key: capabilities.get(key) }), {});
245
239
  }
@@ -299,7 +293,7 @@ async function waitUntilDisplayed(driver, selector, timeout) {
299
293
  exports.waitUntilDisplayed = waitUntilDisplayed;
300
294
  // #endregion
301
295
  // #region MOBILE COMMANDS
302
- async function getBarsHeight(driver) {
296
+ async function getBarsSize(driver) {
303
297
  const { Command } = require('selenium-webdriver/lib/command');
304
298
  const getSystemBarsCommand = new Command('getSystemBars');
305
299
  const { statusBar, navigationBar } = process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
@@ -308,9 +302,18 @@ async function getBarsHeight(driver) {
308
302
  return {
309
303
  statusBarHeight: statusBar.visible ? statusBar.height : 0,
310
304
  navigationBarHeight: navigationBar.visible ? navigationBar.height : 0,
305
+ navigationBarWidth: navigationBar.visible ? navigationBar.width : 0,
311
306
  };
312
307
  }
313
- exports.getBarsHeight = getBarsHeight;
308
+ exports.getBarsSize = getBarsSize;
309
+ async function setOrientation(driver, orientation) {
310
+ const { Command } = require('selenium-webdriver/lib/command');
311
+ const setOrientationCommand = new Command('setOrientation').setParameters({ orientation });
312
+ process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3'
313
+ ? await driver.schedule(setOrientationCommand)
314
+ : await driver.execute(setOrientationCommand);
315
+ }
316
+ exports.setOrientation = setOrientation;
314
317
  async function getOrientation(driver) {
315
318
  const { Command } = require('selenium-webdriver/lib/command');
316
319
  const getOrientationCommand = new Command('getOrientation');
@@ -342,10 +345,7 @@ exports.getElementText = getElementText;
342
345
  async function performAction(driver, steps) {
343
346
  const { Command } = require('selenium-webdriver/lib/command');
344
347
  const performTouchCommand = new Command('performTouch').setParameters({
345
- actions: steps.map((_a) => {
346
- var { action } = _a, options = __rest(_a, ["action"]);
347
- return ({ action, options });
348
- }),
348
+ actions: steps.map(({ action, ...options }) => ({ action, options })),
349
349
  });
350
350
  if (process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3') {
351
351
  await driver.schedule(performTouchCommand);
@@ -364,8 +364,8 @@ const browserOptionsNames = {
364
364
  async function build(env) {
365
365
  var _a;
366
366
  const parseEnv = require('@applitools/test-utils/src/parse-env');
367
- const { browser, capabilities, url, attach, proxy, configurable = true, appium = false, args = [], headless, } = parseEnv(Object.assign(Object.assign({}, env), { legacy: (_a = env.legacy) !== null && _a !== void 0 ? _a : process.env.APPLITOOLS_SELENIUM_MAJOR_VERSION === '3' }));
368
- const desiredCapabilities = Object.assign({}, capabilities);
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 };
369
369
  if (configurable) {
370
370
  const browserOptionsName = browserOptionsNames[browser || desiredCapabilities.browserName];
371
371
  if (browserOptionsName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/spec-driver-selenium",
3
- "version": "1.3.4",
3
+ "version": "1.3.7",
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
- "default": "./dist/index.js",
33
- "types": "./types/index.d.ts"
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.3.0",
62
- "@applitools/utils": "1.2.13"
61
+ "@applitools/types": "1.4.4",
62
+ "@applitools/utils": "1.3.1"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@applitools/api-extractor": "^1.2.7",
66
- "@applitools/bongo": "2.0.0",
66
+ "@applitools/bongo": "2.1.1",
67
67
  "@applitools/scripts": "1.1.0",
68
- "@applitools/test-utils": "1.3.0",
69
- "@types/mocha": "^9.0.0",
70
- "@types/node": "^16.10.2",
71
- "@types/selenium-webdriver": "^4.0.15",
72
- "@typescript-eslint/eslint-plugin": "^4.15.1",
73
- "@typescript-eslint/parser": "^4.15.1",
74
- "eslint": "^7.9.0",
75
- "eslint-config-prettier": "^7.2.0",
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": "^3.3.1",
78
+ "eslint-plugin-prettier": "^4.0.0",
79
79
  "husky": "^4.3.7",
80
- "mocha": "^9.1.2",
81
- "prettier": "^2.4.1",
82
- "selenium-webdriver": "^4.1.1",
83
- "ts-node": "^10.2.1",
84
- "ttypescript": "^1.5.12",
85
- "typescript": "^4.5.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 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>;
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>;