@applitools/driver 1.2.5 → 1.3.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 1.3.1 - 2021/11/14
7
+
8
+ - add in-house capability parsing and system bars size handling mechanisms
9
+ - adjust scrolling algorithm on native devices
10
+ - support cookies
11
+ - updated to @applitools/types@1.0.20 (from 1.0.19)
12
+
13
+ ## 1.3.0 - 2021/11/10
14
+
15
+ - updated to @applitools/types@1.0.19 (from 1.0.18)
16
+
17
+ ## 1.3.0 - 2021/11/10
18
+
19
+ - updated to @applitools/types@1.0.19 (from 1.0.18)
20
+
21
+ ## 1.2.7 - 2021/10/30
22
+
23
+ - updated to @applitools/types@1.0.18 (from 1.0.14)
24
+ - updated to @applitools/utils@1.2.4 (from 1.2.3)
25
+
26
+ ## 1.2.6 - 2021/10/7
27
+
28
+ - fix issue with fractional viewport size on mobile devices
29
+
6
30
  ## 1.2.5 - 2021/10/5
7
31
 
8
32
  - fix issue with wrong user agent overrides valid driver info
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCapabilities = void 0;
4
+ function parseCapabilities(capabilities) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6
+ const info = {
7
+ browserName: ((_a = capabilities.browserName) !== null && _a !== void 0 ? _a : (_b = capabilities.desired) === null || _b === void 0 ? void 0 : _b.browserName) || undefined,
8
+ browserVersion: ((_c = capabilities.browserVersion) !== null && _c !== void 0 ? _c : capabilities.version) || undefined,
9
+ platformName: ((_e = (_d = capabilities.platformName) !== null && _d !== void 0 ? _d : capabilities.platform) !== null && _e !== void 0 ? _e : (_f = capabilities.desired) === null || _f === void 0 ? void 0 : _f.platformName) || undefined,
10
+ platformVersion: capabilities.platformVersion || undefined,
11
+ isW3C: isW3C(capabilities),
12
+ isMobile: isMobile(capabilities),
13
+ };
14
+ if (info.isMobile) {
15
+ info.deviceName = ((_h = (_g = capabilities.desired) === null || _g === void 0 ? void 0 : _g.deviceName) !== null && _h !== void 0 ? _h : capabilities.deviceName) || undefined;
16
+ info.isNative = info.isMobile && !info.browserName;
17
+ info.isIOS = isIOS(capabilities);
18
+ info.isAndroid = isAndroid(capabilities);
19
+ }
20
+ if (info.isNative) {
21
+ info.pixelRatio = capabilities.pixelRatio;
22
+ info.statusBarHeight = capabilities.statBarHeight;
23
+ info.navigationBarHeight = 0;
24
+ }
25
+ return info;
26
+ }
27
+ exports.parseCapabilities = parseCapabilities;
28
+ function isW3C(capabilities) {
29
+ const isW3C = Boolean((capabilities.platformName || capabilities.browserVersion) &&
30
+ (capabilities.platformVersion || capabilities.hasOwnProperty('setWindowRect')));
31
+ return isW3C || isAppium(capabilities);
32
+ }
33
+ function isAppium(capabilities) {
34
+ return (Boolean(capabilities.automationName || capabilities.deviceName || capabilities.appiumVersion) ||
35
+ Object.keys(capabilities).some(cap => cap.startsWith('appium:')));
36
+ }
37
+ function _isChrome(capabilities) {
38
+ return Boolean(capabilities.chrome || capabilities['goog:chromeOptions']);
39
+ }
40
+ function _isFirefox(capabilities) {
41
+ return capabilities.browserName === 'firefox' || Object.keys(capabilities).some(cap => cap.startsWith('moz:'));
42
+ }
43
+ function isMobile(capabilities) {
44
+ var _a, _b;
45
+ return (capabilities.browserName === '' ||
46
+ ['ipad', 'iphone', 'android'].includes((_b = (_a = capabilities.browserName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '') ||
47
+ isAppium(capabilities));
48
+ }
49
+ function isIOS(capabilities) {
50
+ return /iOS/i.test(capabilities.platformName) || /(iPad|iPhone)/i.test(capabilities.deviceName);
51
+ }
52
+ function isAndroid(capabilities) {
53
+ return /Android/i.test(capabilities.platformName) || /Android/i.test(capabilities.browserName);
54
+ }
package/dist/context.js CHANGED
@@ -437,6 +437,13 @@ class Context {
437
437
  }
438
438
  return region;
439
439
  }
440
+ async getCookies() {
441
+ var _a, _b;
442
+ if (this.driver.isNative)
443
+ return [];
444
+ await this.focus();
445
+ return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target, true)) !== null && _b !== void 0 ? _b : [];
446
+ }
440
447
  async preserveInnerOffset() {
441
448
  this._state.innerOffset = await this.getInnerOffset();
442
449
  }
package/dist/driver.js CHANGED
@@ -24,6 +24,7 @@ const utils = __importStar(require("@applitools/utils"));
24
24
  const context_1 = require("./context");
25
25
  const utils_1 = require("./utils");
26
26
  const user_agent_1 = require("./user-agent");
27
+ const capabilities_1 = require("./capabilities");
27
28
  const snippets = require('@applitools/snippets');
28
29
  // eslint-disable-next-line
29
30
  class Driver {
@@ -125,23 +126,43 @@ class Driver {
125
126
  this._currentContext = context;
126
127
  }
127
128
  async init() {
128
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
129
- this._driverInfo = await ((_b = (_a = this._spec).getDriverInfo) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
129
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
130
+ var _s, _t, _u, _v, _w, _x;
131
+ const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
132
+ this._logger.log('Driver capabilities', capabilities);
133
+ const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities) : undefined;
134
+ const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
135
+ this._driverInfo = Object.assign(Object.assign({}, capabilitiesInfo), driverInfo);
130
136
  if (this.isWeb) {
131
- const userAgent = (_d = (_c = this._driverInfo) === null || _c === void 0 ? void 0 : _c.userAgent) !== null && _d !== void 0 ? _d : (await this.execute(snippets.getUserAgent));
132
- const pixelRatio = (_f = (_e = this._driverInfo) === null || _e === void 0 ? void 0 : _e.pixelRatio) !== null && _f !== void 0 ? _f : (await this.execute(snippets.getPixelRatio));
133
- const userAgentInfo = userAgent ? user_agent_1.parseUserAgent(userAgent) : {};
134
- this._driverInfo = Object.assign(Object.assign({}, this._driverInfo), { isMobile: (_h = (_g = this._driverInfo) === null || _g === void 0 ? void 0 : _g.isMobile) !== null && _h !== void 0 ? _h : ['iOS', 'Android'].includes(userAgentInfo.platformName), platformName: ((_j = this._driverInfo) === null || _j === void 0 ? void 0 : _j.isMobile)
135
- ? (_l = (_k = this._driverInfo) === null || _k === void 0 ? void 0 : _k.platformName) !== null && _l !== void 0 ? _l : userAgentInfo.platformName
136
- : (_m = userAgentInfo.platformName) !== null && _m !== void 0 ? _m : (_o = this._driverInfo) === null || _o === void 0 ? void 0 : _o.platformName, platformVersion: ((_p = this._driverInfo) === null || _p === void 0 ? void 0 : _p.isMobile)
137
- ? (_r = (_q = this._driverInfo) === null || _q === void 0 ? void 0 : _q.platformVersion) !== null && _r !== void 0 ? _r : userAgentInfo.platformVersion
138
- : (_s = userAgentInfo.platformVersion) !== null && _s !== void 0 ? _s : (_t = this._driverInfo) === null || _t === void 0 ? void 0 : _t.platformVersion, browserName: (_u = userAgentInfo.browserName) !== null && _u !== void 0 ? _u : (_v = this._driverInfo) === null || _v === void 0 ? void 0 : _v.browserName, browserVersion: (_w = userAgentInfo.browserVersion) !== null && _w !== void 0 ? _w : (_x = this._driverInfo) === null || _x === void 0 ? void 0 : _x.browserVersion, userAgent,
139
- pixelRatio });
137
+ (_e = (_s = this._driverInfo).pixelRatio) !== null && _e !== void 0 ? _e : (_s.pixelRatio = await this.execute(snippets.getPixelRatio));
138
+ (_f = (_t = this._driverInfo).userAgent) !== null && _f !== void 0 ? _f : (_t.userAgent = await this.execute(snippets.getUserAgent));
139
+ if (this._driverInfo.userAgent) {
140
+ const userAgentInfo = user_agent_1.parseUserAgent(this._driverInfo.userAgent);
141
+ this._driverInfo.browserName = (_g = userAgentInfo.browserName) !== null && _g !== void 0 ? _g : this._driverInfo.browserName;
142
+ this._driverInfo.browserVersion = (_h = userAgentInfo.browserVersion) !== null && _h !== void 0 ? _h : this._driverInfo.browserVersion;
143
+ if (!this._driverInfo.isMobile) {
144
+ (_j = (_u = this._driverInfo).platformName) !== null && _j !== void 0 ? _j : (_u.platformName = userAgentInfo.platformName);
145
+ (_k = (_v = this._driverInfo).platformVersion) !== null && _k !== void 0 ? _k : (_v.platformVersion = userAgentInfo.platformVersion);
146
+ }
147
+ else {
148
+ this._driverInfo.platformName = (_l = userAgentInfo.platformName) !== null && _l !== void 0 ? _l : this._driverInfo.platformName;
149
+ this._driverInfo.platformVersion = (_m = userAgentInfo.platformVersion) !== null && _m !== void 0 ? _m : this._driverInfo.platformVersion;
150
+ }
151
+ }
152
+ (_o = (_w = this._driverInfo).features) !== null && _o !== void 0 ? _o : (_w.features = {});
153
+ (_p = (_x = this._driverInfo.features).allCookies) !== null && _p !== void 0 ? _p : (_x.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
140
154
  }
141
155
  else {
142
- if (this.isAndroid) {
143
- this._driverInfo.statusBarHeight = this._driverInfo.statusBarHeight / this.pixelRatio;
144
- this._driverInfo.navigationBarHeight = this._driverInfo.navigationBarHeight / this.pixelRatio;
156
+ if (this.isNative) {
157
+ const barsHeight = await ((_r = (_q = this._spec).getBarsHeight) === null || _r === void 0 ? void 0 : _r.call(_q, this.target).catch(() => undefined));
158
+ if (barsHeight) {
159
+ this._driverInfo.statusBarHeight = Math.max(barsHeight.statusBarHeight, driverInfo.statusBarHeight);
160
+ this._driverInfo.navigationBarHeight = Math.max(barsHeight.navigationBarHeight, driverInfo.navigationBarHeight);
161
+ }
162
+ if (this.isAndroid) {
163
+ this._driverInfo.statusBarHeight /= this.pixelRatio;
164
+ this._driverInfo.navigationBarHeight /= this.pixelRatio;
165
+ }
145
166
  }
146
167
  if (!this._driverInfo.viewportSize) {
147
168
  const displaySize = await this.getDisplaySize();
@@ -151,7 +172,7 @@ class Driver {
151
172
  };
152
173
  }
153
174
  }
154
- this._logger.log('Driver initialized', this._driverInfo);
175
+ this._logger.log('Combined driver info', this._driverInfo);
155
176
  return this;
156
177
  }
157
178
  async refreshContexts() {
@@ -354,6 +375,7 @@ class Driver {
354
375
  }
355
376
  }
356
377
  }
378
+ size = utils.geometry.round(size);
357
379
  }
358
380
  else if (this._spec.getViewportSize) {
359
381
  this._logger.log('Extracting viewport size from web driver using spec method');
@@ -411,6 +433,12 @@ class Driver {
411
433
  this._logger.log('Extracted device orientation:', orientation);
412
434
  return orientation;
413
435
  }
436
+ async getCookies() {
437
+ var _a, _b;
438
+ if (this.isNative || !this.features.allCookies)
439
+ return [];
440
+ return (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.getCookies(this.target)) !== null && _b !== void 0 ? _b : [];
441
+ }
414
442
  async getTitle() {
415
443
  if (this.isNative)
416
444
  return null;
package/dist/element.js CHANGED
@@ -309,12 +309,20 @@ class Element {
309
309
  let remainingOffset;
310
310
  if (offset.x === 0 && offset.y === 0) {
311
311
  requiredOffset = offset;
312
- remainingOffset = { x: -maxOffset.x, y: -maxOffset.y };
312
+ // if it has to be scrolled to the very beginning, then scroll maximum amount of pixels and a bit extra to be sure
313
+ remainingOffset = { x: -(maxOffset.x + 0), y: -(maxOffset.y + 0) };
313
314
  }
314
315
  else {
315
316
  requiredOffset = { x: Math.min(offset.x, maxOffset.x), y: Math.min(offset.y, maxOffset.y) };
316
317
  remainingOffset = utils.geometry.offsetNegative(requiredOffset, currentScrollOffset);
318
+ // if it has to be scrolled to the very end, then do a bit of extra scrolling to be sure
319
+ // if (requiredOffset.x === maxOffset.x) remainingOffset.x += 100
320
+ // if (requiredOffset.y === maxOffset.y) remainingOffset.y += 100
317
321
  }
322
+ // if (requiredOffset.x === 0) remainingOffset.x -= 100
323
+ // if (requiredOffset.y === 0) remainingOffset.y -= 100
324
+ // if (requiredOffset.x === maxOffset.x) remainingOffset.x += 100
325
+ // if (requiredOffset.y === maxOffset.y) remainingOffset.y += 100
318
326
  if (this.driver.isAndroid) {
319
327
  remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
320
328
  }
@@ -330,7 +338,7 @@ class Element {
330
338
  actions.push({ action: 'press', x: xStart, y: yCenter }, { action: 'wait', ms: 1500 }, { action: 'moveTo', x: xEnd, y: yCenter }, { action: 'release' });
331
339
  xRemaining -= xRight - xLeft;
332
340
  }
333
- const yPadding = Math.floor(scrollableRegion.height * 0.1);
341
+ const yPadding = Math.floor(scrollableRegion.height * 0.08);
334
342
  const xCenter = Math.floor(scrollableRegion.x + scrollableRegion.width / 2); // 0
335
343
  const yTop = scrollableRegion.y + yPadding;
336
344
  const yDirection = remainingOffset.y > 0 ? 'down' : 'up';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.spec = exports.MockDriver = void 0;
23
+ var mock_driver_1 = require("./mock-driver");
24
+ Object.defineProperty(exports, "MockDriver", { enumerable: true, get: function () { return mock_driver_1.MockDriver; } });
25
+ exports.spec = __importStar(require("./spec-driver"));
@@ -1,3 +1,7 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MockDriver = void 0;
1
5
  const { inspect } = require('util');
2
6
  const utils = require('@applitools/utils');
3
7
  const snippets = require('@applitools/snippets');
@@ -18,7 +22,8 @@ const DEFAULT_PROPS = {
18
22
  overflow: null,
19
23
  };
20
24
  class MockDriver {
21
- constructor({ viewport = { width: 1000, height: 1000 }, device, platform, browser, ua } = {}) {
25
+ constructor(options = {}) {
26
+ const { viewport = { width: 1000, height: 1000 }, device, platform, browser, ua } = options;
22
27
  this._device = device;
23
28
  this._platform = platform;
24
29
  this._browser = browser;
@@ -336,4 +341,4 @@ class MockDriver {
336
341
  return '<MockDriver>';
337
342
  }
338
343
  }
339
- module.exports = { MockDriver };
344
+ exports.MockDriver = MockDriver;
@@ -1,66 +1,104 @@
1
- const utils = require('@applitools/utils');
2
- const spec = {
3
- isDriver(driver) {
4
- return driver && driver.constructor.name === 'MockDriver';
5
- },
6
- isElement(element) {
7
- return utils.types.has(element, 'id');
8
- },
9
- isSelector(selector) {
10
- return utils.types.isString(selector) || utils.types.has(selector, ['using', 'value']);
11
- },
12
- transformSelector(selector) {
13
- return selector.selector || selector;
14
- },
15
- isStaleElementError() {
16
- return false;
17
- },
18
- isEqualElements(_driver, element1, element2) {
19
- return element1.id === element2.id;
20
- },
21
- executeScript(driver, script, ...args) {
22
- return driver.executeScript(script, args);
23
- },
24
- findElement(driver, selector, parent) {
25
- return driver.findElement(selector.selector || selector, parent);
26
- },
27
- findElements(driver, selector, parent) {
28
- return driver.findElements(selector.selector || selector, parent);
29
- },
30
- mainContext(driver) {
31
- return driver.switchToFrame(null);
32
- },
33
- parentContext(driver) {
34
- return driver.switchToParentFrame();
35
- },
36
- childContext(driver, reference) {
37
- return driver.switchToFrame(reference);
38
- },
39
- takeScreenshot(driver) {
40
- return driver.takeScreenshot();
41
- },
42
- getDriverInfo(driver) {
43
- return driver.info;
44
- },
45
- async getWindowSize(driver) {
46
- const rect = await driver.getWindowRect();
47
- return rect;
48
- },
49
- async setWindowSize(driver, size) {
50
- await driver.setWindowRect(size);
51
- },
52
- async getUrl(driver) {
53
- if (this._isNative)
54
- return null;
55
- return driver.getUrl();
56
- },
57
- async getTitle(driver) {
58
- if (this._isNative)
59
- return null;
60
- return driver.getTitle();
61
- },
62
- async visit(driver, url) {
63
- await driver.visit(url);
64
- },
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
65
20
  };
66
- module.exports = { spec };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.visit = exports.getTitle = exports.getUrl = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.transformSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
23
+ const utils = __importStar(require("@applitools/utils"));
24
+ function isDriver(driver) {
25
+ return driver && driver.constructor.name === 'MockDriver';
26
+ }
27
+ exports.isDriver = isDriver;
28
+ function isElement(element) {
29
+ return utils.types.has(element, 'id');
30
+ }
31
+ exports.isElement = isElement;
32
+ function isSelector(selector) {
33
+ return utils.types.isString(selector) || utils.types.has(selector, ['using', 'value']);
34
+ }
35
+ exports.isSelector = isSelector;
36
+ function transformSelector(selector) {
37
+ return utils.types.has(selector, 'selector') ? selector.selector : selector;
38
+ }
39
+ exports.transformSelector = transformSelector;
40
+ function isStaleElementError() {
41
+ return false;
42
+ }
43
+ exports.isStaleElementError = isStaleElementError;
44
+ async function isEqualElements(_driver, element1, element2) {
45
+ return element1.id === element2.id;
46
+ }
47
+ exports.isEqualElements = isEqualElements;
48
+ async function executeScript(driver, script, arg) {
49
+ return driver.executeScript(script, [arg]);
50
+ }
51
+ exports.executeScript = executeScript;
52
+ async function findElement(driver, selector, parent) {
53
+ return driver.findElement(selector, parent);
54
+ }
55
+ exports.findElement = findElement;
56
+ async function findElements(driver, selector, parent) {
57
+ return driver.findElements(selector, parent);
58
+ }
59
+ exports.findElements = findElements;
60
+ async function mainContext(driver) {
61
+ return driver.switchToFrame(null);
62
+ }
63
+ exports.mainContext = mainContext;
64
+ async function parentContext(driver) {
65
+ return driver.switchToParentFrame();
66
+ }
67
+ exports.parentContext = parentContext;
68
+ async function childContext(driver, element) {
69
+ return driver.switchToFrame(element);
70
+ }
71
+ exports.childContext = childContext;
72
+ async function takeScreenshot(driver) {
73
+ return driver.takeScreenshot();
74
+ }
75
+ exports.takeScreenshot = takeScreenshot;
76
+ async function getDriverInfo(driver) {
77
+ return driver.info;
78
+ }
79
+ exports.getDriverInfo = getDriverInfo;
80
+ async function getWindowSize(driver) {
81
+ const rect = await driver.getWindowRect();
82
+ return rect;
83
+ }
84
+ exports.getWindowSize = getWindowSize;
85
+ async function setWindowSize(driver, size) {
86
+ await driver.setWindowRect(size);
87
+ }
88
+ exports.setWindowSize = setWindowSize;
89
+ async function getUrl(driver) {
90
+ if (this._isNative)
91
+ return null;
92
+ return driver.getUrl();
93
+ }
94
+ exports.getUrl = getUrl;
95
+ async function getTitle(driver) {
96
+ if (this._isNative)
97
+ return null;
98
+ return driver.getTitle();
99
+ }
100
+ exports.getTitle = getTitle;
101
+ async function visit(driver, url) {
102
+ await driver.visit(url);
103
+ }
104
+ exports.visit = visit;
package/dist/index.js CHANGED
@@ -6,25 +6,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
6
6
  if (k2 === undefined) k2 = k;
7
7
  o[k2] = m[k];
8
8
  }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
11
  };
17
- var __importStar = (this && this.__importStar) || function (mod) {
18
- if (mod && mod.__esModule) return mod;
19
- var result = {};
20
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
- __setModuleDefault(result, mod);
22
- return result;
23
- };
24
12
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.fake = void 0;
26
13
  __exportStar(require("./driver"), exports);
27
14
  __exportStar(require("./context"), exports);
28
15
  __exportStar(require("./element"), exports);
29
- __exportStar(require("./fake/mock-driver"), exports);
30
- exports.fake = __importStar(require("./fake/spec-driver"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.2.5",
3
+ "version": "1.3.1",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git://github.com/applitools/eyes.sdk.javascript1.git"
19
+ "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
20
+ "directory": "packages/driver"
20
21
  },
21
22
  "license": "SEE LICENSE IN LICENSE",
22
23
  "author": {
@@ -25,12 +26,22 @@
25
26
  },
26
27
  "main": "./dist/index.js",
27
28
  "types": "./types/index.d.ts",
28
- "directories": {
29
- "lib": "./src",
30
- "test": "./test"
29
+ "exports": {
30
+ ".": {
31
+ "default": "./dist/index.js",
32
+ "types": "./types/index.d.ts"
33
+ },
34
+ "./fake": {
35
+ "default": "./dist/fake/index.js",
36
+ "types": "./types/fake/index.d.ts"
37
+ }
31
38
  },
39
+ "files": [
40
+ "dist",
41
+ "types"
42
+ ],
32
43
  "scripts": {
33
- "lint": "eslint '**/*.ts' '**/*.js'",
44
+ "lint": "eslint '**/*.ts'",
34
45
  "build": "tsc",
35
46
  "test": "mocha --no-timeouts -r ts-node/register ./test/**/*.spec.ts",
36
47
  "deps": "bongo deps",
@@ -45,11 +56,11 @@
45
56
  },
46
57
  "dependencies": {
47
58
  "@applitools/snippets": "2.1.7",
48
- "@applitools/types": "1.0.14",
49
- "@applitools/utils": "1.2.3"
59
+ "@applitools/types": "1.0.20",
60
+ "@applitools/utils": "1.2.4"
50
61
  },
51
62
  "devDependencies": {
52
- "@applitools/sdk-release-kit": "0.13.3",
63
+ "@applitools/sdk-release-kit": "0.13.4",
53
64
  "@types/mocha": "^9.0.0",
54
65
  "@types/node": "^16.3.3",
55
66
  "@typescript-eslint/eslint-plugin": "^4.28.3",
@@ -0,0 +1,4 @@
1
+ import type * as types from '@applitools/types';
2
+ declare type Capabilities = Record<string, any>;
3
+ export declare function parseCapabilities(capabilities: Capabilities): types.DriverInfo;
4
+ export {};
@@ -0,0 +1,71 @@
1
+ import type * as types from '@applitools/types';
2
+ import type { Driver } from './driver';
3
+ import { Element } from './element';
4
+ export declare type ContextReference<TDriver, TContext, TElement, TSelector> = Context<TDriver, TContext, TElement, TSelector> | Element<TDriver, TContext, TElement, TSelector> | TElement | types.Selector<TSelector> | string | number;
5
+ export declare type ContextPlain<TDriver, TContext, TElement, TSelector> = ContextReference<TDriver, TContext, TElement, TSelector> | {
6
+ reference: ContextReference<TDriver, TContext, TElement, TSelector>;
7
+ scrollingElement?: Element<TDriver, TContext, TElement, TSelector>;
8
+ parent?: ContextPlain<TDriver, TContext, TElement, TSelector>;
9
+ };
10
+ export declare type ContextState = {
11
+ region?: types.Region;
12
+ clientRegion?: types.Region;
13
+ scrollingRegion?: types.Region;
14
+ innerOffset?: types.Location;
15
+ };
16
+ export declare class Context<TDriver, TContext, TElement, TSelector> {
17
+ private _target;
18
+ private _driver;
19
+ private _parent;
20
+ private _element;
21
+ private _reference;
22
+ private _scrollingElement;
23
+ private _state;
24
+ private _logger;
25
+ private _utils;
26
+ private _isReference;
27
+ protected readonly _spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
28
+ constructor(options: {
29
+ spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;
30
+ context?: TContext | Context<TDriver, TContext, TElement, TSelector>;
31
+ driver?: Driver<TDriver, TContext, TElement, TSelector>;
32
+ parent?: Context<TDriver, TContext, TElement, TSelector>;
33
+ reference?: ContextReference<TDriver, TContext, TElement, TSelector>;
34
+ element?: Element<TDriver, TContext, TElement, TSelector>;
35
+ scrollingElement?: Element<TDriver, TContext, TElement, TSelector>;
36
+ logger?: any;
37
+ });
38
+ get target(): TContext;
39
+ get driver(): Driver<TDriver, TContext, TElement, TSelector>;
40
+ get parent(): Context<TDriver, TContext, TElement, TSelector> | null;
41
+ get main(): Context<TDriver, TContext, TElement, TSelector>;
42
+ get path(): Context<TDriver, TContext, TElement, TSelector>[];
43
+ get isMain(): boolean;
44
+ get isCurrent(): boolean;
45
+ get isInitialized(): boolean;
46
+ get isRef(): boolean;
47
+ init(): Promise<this>;
48
+ focus(): Promise<this>;
49
+ equals(context: Context<TDriver, TContext, TElement, TSelector> | Element<TDriver, TContext, TElement, TSelector>): Promise<boolean>;
50
+ context(reference: ContextPlain<TDriver, TContext, TElement, TSelector>): Promise<Context<TDriver, TContext, TElement, TSelector>>;
51
+ element(elementOrSelector: TElement | types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>>;
52
+ elements(elementOrSelector: TElement | types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>[]>;
53
+ execute(script: ((args: any) => any) | string, arg?: any): Promise<any>;
54
+ getContextElement(): Promise<Element<TDriver, TContext, TElement, TSelector>>;
55
+ getScrollingElement(): Promise<Element<TDriver, TContext, TElement, TSelector>>;
56
+ setScrollingElement(scrollingElement: Element<TDriver, TContext, TElement, TSelector> | TElement | types.Selector<TSelector>): Promise<void>;
57
+ blurElement(element?: Element<TDriver, TContext, TElement, TSelector>): Promise<TElement>;
58
+ focusElement(element: Element<TDriver, TContext, TElement, TSelector>): Promise<any>;
59
+ getRegion(): Promise<types.Region>;
60
+ getClientRegion(): Promise<types.Region>;
61
+ getScrollingRegion(): Promise<types.Region>;
62
+ getContentSize(): Promise<types.Size>;
63
+ getInnerOffset(): Promise<types.Location>;
64
+ getLocationInMainContext(): Promise<types.Location>;
65
+ getLocationInViewport(): Promise<types.Location>;
66
+ getRegionInViewport(region: types.Region): Promise<types.Region>;
67
+ getCookies(): Promise<types.Cookie[]>;
68
+ private preserveInnerOffset;
69
+ private preserveContextRegions;
70
+ private preserveScrollingRegion;
71
+ }