@applitools/driver 1.4.2 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 1.4.6 - 2021/12/22
7
+
8
+ - extract device orientation in `Driver`'s `init` and provide readonly access through the `orientation` getter of the `Driver`
9
+ - updated to @applitools/snippets@2.1.11 (from 2.1.10)
10
+ - updated to @applitools/types@1.0.23 (from 1.0.22)
11
+ - updated to @applitools/utils@1.2.5 (from 1.2.4)
12
+
13
+ ## 1.4.5 - 2021/12/20
14
+
15
+ - improve native android app scrolling performance
16
+ - fix bug with `Buffer.from` and base64
17
+ - updated to @applitools/snippets@2.1.10 (from 2.1.9)
18
+
19
+ ## 1.4.3 - 2021/12/17
20
+
21
+ - convert base64 result of `spec.takeScreenshot` to `Buffer` before return it from `Driver`'s `takeScreenshot` method
22
+ - updated to @applitools/snippets@2.1.9 (from 2.1.8)
23
+
6
24
  ## 1.4.2 - 2021/12/16
7
25
 
8
26
  - fix exports subpathes
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.checkSpecDriver = void 0;
7
- const strict_1 = __importDefault(require("assert/strict"));
4
+ const assert_1 = require("assert");
8
5
  const snippets = require('@applitools/snippets');
9
6
  async function checkSpecDriver(options) {
10
7
  const { spec, driver } = options;
@@ -13,7 +10,7 @@ async function checkSpecDriver(options) {
13
10
  'execute script with echo snippet': async () => {
14
11
  const arg = [1, '23', false, { a: 4, b: [5] }, null];
15
12
  const result = await spec.executeScript(context, 'return arguments[0]', arg);
16
- strict_1.default.deepEqual(result, arg, 'script returns an array of json data');
13
+ assert_1.strict.deepEqual(result, arg, 'script returns an array of json data');
17
14
  },
18
15
  'execute script with functional script': async () => {
19
16
  const arg = { a: 2, b: 1, c: 7 };
@@ -21,23 +18,23 @@ async function checkSpecDriver(options) {
21
18
  return arg;
22
19
  }
23
20
  const result = await spec.executeScript(context, script, arg);
24
- strict_1.default.deepEqual(result, arg, 'script returns an array of json data from functional script');
21
+ assert_1.strict.deepEqual(result, arg, 'script returns an array of json data from functional script');
25
22
  },
26
23
  'execute script with return value of dom element': async () => {
27
24
  const element = await spec.executeScript(context, 'return document.documentElement');
28
25
  const isHtmlElement = await spec.executeScript(context, 'return arguments[0] === document.documentElement', element);
29
- strict_1.default.ok(isHtmlElement, 'script returns an element and could be executed with an element');
26
+ assert_1.strict.ok(isHtmlElement, 'script returns an element and could be executed with an element');
30
27
  },
31
28
  'execute script with nested element references': async () => {
32
29
  const elements = await spec.executeScript(context, 'return [{html: document.documentElement, body: document.body}]');
33
30
  const isElements = await spec.executeScript(context, 'return arguments[0][0].html === document.documentElement && arguments[0][0].html === document.documentElement', elements);
34
- strict_1.default.ok(isElements, 'script returns elements inside nested structure and could be executed with a nested structure of elements');
31
+ assert_1.strict.ok(isElements, 'script returns elements inside nested structure and could be executed with a nested structure of elements');
35
32
  },
36
33
  'find element with string selector': async () => {
37
34
  const selector = transformSelector('html>body>h1');
38
35
  const element = await spec.findElement(context, selector);
39
36
  const isWantedElement = await spec.executeScript(context, `return arguments[0] === document.querySelector("${selector}")`, element);
40
- strict_1.default.ok(isWantedElement, `returns element by string selector - "${selector}"`);
37
+ assert_1.strict.ok(isWantedElement, `returns element by string selector - "${selector}"`);
41
38
  },
42
39
  'find element with spec selector': async () => {
43
40
  const cssSelector = transformSelector({ type: 'css', selector: 'html>body>h1' });
@@ -45,21 +42,21 @@ async function checkSpecDriver(options) {
45
42
  const verificationScript = `return arguments[0] === document.querySelector('html>body>h1')`;
46
43
  const cssElement = await spec.findElement(context, cssSelector);
47
44
  const isCssElement = await spec.executeScript(context, verificationScript, cssElement);
48
- strict_1.default.ok(isCssElement, `returns element by spec selector - ${JSON.stringify(cssSelector)}`);
45
+ assert_1.strict.ok(isCssElement, `returns element by spec selector - ${JSON.stringify(cssSelector)}`);
49
46
  const xpathElement = await spec.findElement(context, xpathSelector);
50
47
  const isXpathElement = await spec.executeScript(context, verificationScript, xpathElement);
51
- strict_1.default.ok(isXpathElement, `returns element by spec selector - ${JSON.stringify(xpathSelector)}`);
48
+ assert_1.strict.ok(isXpathElement, `returns element by spec selector - ${JSON.stringify(xpathSelector)}`);
52
49
  },
53
50
  'find element with unresolvable selector': async () => {
54
51
  const selector = transformSelector('unresolvable_selector');
55
52
  const element = await spec.findElement(context, selector);
56
- strict_1.default.equal(element, null, `returns null by unresolvable selector - "${selector}"`);
53
+ assert_1.strict.equal(element, null, `returns null by unresolvable selector - "${selector}"`);
57
54
  },
58
55
  'find elements with string selector': async () => {
59
56
  const selector = transformSelector('html p');
60
57
  const elements = await spec.findElements(context, selector);
61
58
  const isExpectedElements = await spec.executeScript(context, `var expected = arguments[0]; return Array.prototype.every.call(document.querySelectorAll("${selector}"), function(element, index) { return element === expected[index] })`, elements);
62
- strict_1.default.ok(isExpectedElements, `returns elements by string selector - "${selector}"`);
59
+ assert_1.strict.ok(isExpectedElements, `returns elements by string selector - "${selector}"`);
63
60
  },
64
61
  'find elements with spec selector': async () => {
65
62
  const cssSelector = transformSelector({ type: 'css', selector: 'html p' });
@@ -67,22 +64,22 @@ async function checkSpecDriver(options) {
67
64
  const verificationScript = `var expected = arguments[0]; return Array.prototype.every.call(document.querySelectorAll('html p'), function(element, index) { return element === expected[index] })`;
68
65
  const cssElements = await spec.findElements(context, cssSelector);
69
66
  const isCssElements = await spec.executeScript(context, verificationScript, cssElements);
70
- strict_1.default.ok(isCssElements, `returns elements by spec selector - ${JSON.stringify(cssSelector)}`);
67
+ assert_1.strict.ok(isCssElements, `returns elements by spec selector - ${JSON.stringify(cssSelector)}`);
71
68
  const xpathElements = await spec.findElements(context, xpathSelector);
72
69
  const isXpathElements = await spec.executeScript(context, verificationScript, xpathElements);
73
- strict_1.default.ok(isXpathElements, `returns element by spec selector - ${JSON.stringify(xpathSelector)}`);
70
+ assert_1.strict.ok(isXpathElements, `returns element by spec selector - ${JSON.stringify(xpathSelector)}`);
74
71
  },
75
72
  'find elements with unresolvable selector': async () => {
76
73
  const selector = transformSelector('unresolvable_selector');
77
74
  const element = await spec.findElements(context, selector);
78
- strict_1.default.deepEqual(element, [], `returns empty array by unresolvable selector - "${selector}"`);
75
+ assert_1.strict.deepEqual(element, [], `returns empty array by unresolvable selector - "${selector}"`);
79
76
  },
80
77
  'child context': async () => {
81
78
  const element = await spec.findElement(context, transformSelector('[name="frame1"]'));
82
79
  const childContext = await spec.childContext(context, element);
83
80
  const inFrame = await spec.executeScript(childContext, 'return window.frameElement.name === "frame1"');
84
- strict_1.default.ok(inFrame, 'returns or switches to a child context');
85
- strict_1.default.ok(typeof spec.mainContext === 'function', 'spec.mainContext also needs to be implemented in order to test spec.childContext');
81
+ assert_1.strict.ok(inFrame, 'returns or switches to a child context');
82
+ assert_1.strict.ok(typeof spec.mainContext === 'function', 'spec.mainContext also needs to be implemented in order to test spec.childContext');
86
83
  await spec.mainContext(context);
87
84
  },
88
85
  'is equal elements': async () => {
@@ -90,53 +87,53 @@ async function checkSpecDriver(options) {
90
87
  return { skipped: true };
91
88
  const htmlEl = await spec.findElement(context, transformSelector('html'));
92
89
  const htmlEl2 = await spec.executeScript(context, 'return document.documentElement');
93
- strict_1.default.ok(await spec.isEqualElements(context, htmlEl, htmlEl2), 'elements should be equal');
90
+ assert_1.strict.ok(await spec.isEqualElements(context, htmlEl, htmlEl2), 'elements should be equal');
94
91
  const bodyEl = await spec.executeScript(context, 'return document.body');
95
- strict_1.default.ok(!(await spec.isEqualElements(context, htmlEl, bodyEl)), 'elements should not be equal');
96
- strict_1.default.ok(!(await spec.isEqualElements(context, htmlEl, undefined)), 'isEqualElements should return false if one of the arguments is falsy');
97
- strict_1.default.ok(!(await spec.isEqualElements(context, undefined, htmlEl)), 'isEqualElements should return false if one of the arguments is falsy');
92
+ assert_1.strict.ok(!(await spec.isEqualElements(context, htmlEl, bodyEl)), 'elements should not be equal');
93
+ assert_1.strict.ok(!(await spec.isEqualElements(context, htmlEl, undefined)), 'isEqualElements should return false if one of the arguments is falsy');
94
+ assert_1.strict.ok(!(await spec.isEqualElements(context, undefined, htmlEl)), 'isEqualElements should return false if one of the arguments is falsy');
98
95
  },
99
96
  'main context': async () => {
100
97
  const mainDocument1 = await spec.findElement(context, transformSelector('html'));
101
98
  const childContext1 = await spec.childContext(context, await spec.findElement(context, transformSelector('[name="frame1"]')));
102
99
  const childContext2 = await spec.childContext(childContext1, await spec.findElement(childContext1, transformSelector('[name="frame1-1"]')));
103
100
  const frameDocument = await spec.findElement(childContext2, transformSelector('html'));
104
- strict_1.default.ok(!(await isEqualElements(childContext2, mainDocument1, frameDocument)));
101
+ assert_1.strict.ok(!(await isEqualElements(childContext2, mainDocument1, frameDocument)));
105
102
  const mainContext = await spec.mainContext(childContext2);
106
103
  const mainDocument2 = await spec.findElement(mainContext, transformSelector('html'));
107
- strict_1.default.ok(await isEqualElements(mainContext, mainDocument2, mainDocument1));
104
+ assert_1.strict.ok(await isEqualElements(mainContext, mainDocument2, mainDocument1));
108
105
  },
109
106
  'parent context': async () => {
110
107
  const parentContext1 = await spec.childContext(context, await spec.findElement(context, transformSelector('[name="frame1"]')));
111
108
  const parentDocument1 = await spec.findElement(parentContext1, transformSelector('html'));
112
109
  const frameContext = await spec.childContext(parentContext1, await spec.findElement(parentContext1, transformSelector('[name="frame1-1"]')));
113
110
  const frameDocument = await spec.findElement(frameContext, transformSelector('html'));
114
- strict_1.default.ok(!(await isEqualElements(frameContext, parentDocument1, frameDocument)));
111
+ assert_1.strict.ok(!(await isEqualElements(frameContext, parentDocument1, frameDocument)));
115
112
  const parentContext2 = await spec.parentContext(frameContext);
116
113
  const parentDocument2 = await spec.findElement(parentContext2, transformSelector('html'));
117
- strict_1.default.ok(await isEqualElements(parentContext2, parentDocument2, parentDocument1));
114
+ assert_1.strict.ok(await isEqualElements(parentContext2, parentDocument2, parentDocument1));
118
115
  await spec.mainContext(context);
119
116
  },
120
117
  'get title': async () => {
121
118
  const title = await spec.getTitle(driver);
122
- strict_1.default.equal(title, 'Cross SDK test', 'returns title of the current page');
119
+ assert_1.strict.equal(title, 'Cross SDK test', 'returns title of the current page');
123
120
  },
124
121
  'get url': async () => {
125
122
  const url = await spec.getUrl(driver);
126
- strict_1.default.equal(url, 'https://applitools.github.io/demo/TestPages/FramesTestPage/', 'returns url of the current page');
123
+ assert_1.strict.equal(url, 'https://applitools.github.io/demo/TestPages/FramesTestPage/', 'returns url of the current page');
127
124
  },
128
125
  'is driver': async () => {
129
- strict_1.default.ok(await spec.isDriver(driver), 'driver should be considered a driver :)');
130
- strict_1.default.ok(!(await spec.isDriver(undefined)), 'undefined should not be considered a driver');
131
- strict_1.default.ok(!(await spec.isDriver(3)), 'number should not be considered a driver');
132
- strict_1.default.ok(!(await spec.isDriver('str')), 'string should not be considered a driver');
126
+ assert_1.strict.ok(await spec.isDriver(driver), 'driver should be considered a driver :)');
127
+ assert_1.strict.ok(!(await spec.isDriver(undefined)), 'undefined should not be considered a driver');
128
+ assert_1.strict.ok(!(await spec.isDriver(3)), 'number should not be considered a driver');
129
+ assert_1.strict.ok(!(await spec.isDriver('str')), 'string should not be considered a driver');
133
130
  },
134
131
  'is element': async () => {
135
132
  const el = await spec.findElement(context, transformSelector('html'));
136
- strict_1.default.ok(await spec.isElement(el), 'element should be considered an element :)');
137
- strict_1.default.ok(!(await spec.isElement(undefined)), 'undefined should not be considered an element');
138
- strict_1.default.ok(!(await spec.isElement(3)), 'number should not be considered an element');
139
- strict_1.default.ok(!(await spec.isElement('str')), 'str should not be considered an element');
133
+ assert_1.strict.ok(await spec.isElement(el), 'element should be considered an element :)');
134
+ assert_1.strict.ok(!(await spec.isElement(undefined)), 'undefined should not be considered an element');
135
+ assert_1.strict.ok(!(await spec.isElement(3)), 'number should not be considered an element');
136
+ assert_1.strict.ok(!(await spec.isElement('str')), 'str should not be considered an element');
140
137
  },
141
138
  // 'is selector': async () => {}, // hard to test this
142
139
  // 'set window size': async () => {}, // hard to test this
package/dist/driver.js CHANGED
@@ -92,6 +92,9 @@ class Driver {
92
92
  var _a;
93
93
  return (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.userAgent;
94
94
  }
95
+ get orientation() {
96
+ return this._driverInfo.orientation;
97
+ }
95
98
  get pixelRatio() {
96
99
  var _a;
97
100
  return (_a = this._driverInfo.pixelRatio) !== null && _a !== void 0 ? _a : 1;
@@ -131,31 +134,31 @@ class Driver {
131
134
  this._currentContext = context;
132
135
  }
133
136
  async init() {
134
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
135
- var _s, _t, _u, _v, _w, _x;
137
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
138
+ var _t, _u, _v, _w, _x, _y, _z;
136
139
  const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
137
140
  this._logger.log('Driver capabilities', capabilities);
138
141
  const capabilitiesInfo = capabilities ? capabilities_1.parseCapabilities(capabilities) : undefined;
139
142
  const driverInfo = await ((_d = (_c = this._spec).getDriverInfo) === null || _d === void 0 ? void 0 : _d.call(_c, this.target));
140
143
  this._driverInfo = Object.assign(Object.assign({}, capabilitiesInfo), driverInfo);
141
144
  if (this.isWeb) {
142
- (_e = (_s = this._driverInfo).pixelRatio) !== null && _e !== void 0 ? _e : (_s.pixelRatio = await this.execute(snippets.getPixelRatio));
143
- (_f = (_t = this._driverInfo).userAgent) !== null && _f !== void 0 ? _f : (_t.userAgent = await this.execute(snippets.getUserAgent));
145
+ (_e = (_t = this._driverInfo).pixelRatio) !== null && _e !== void 0 ? _e : (_t.pixelRatio = await this.execute(snippets.getPixelRatio));
146
+ (_f = (_u = this._driverInfo).userAgent) !== null && _f !== void 0 ? _f : (_u.userAgent = await this.execute(snippets.getUserAgent));
144
147
  if (this._driverInfo.userAgent) {
145
148
  const userAgentInfo = user_agent_1.parseUserAgent(this._driverInfo.userAgent);
146
149
  this._driverInfo.browserName = (_g = userAgentInfo.browserName) !== null && _g !== void 0 ? _g : this._driverInfo.browserName;
147
150
  this._driverInfo.browserVersion = (_h = userAgentInfo.browserVersion) !== null && _h !== void 0 ? _h : this._driverInfo.browserVersion;
148
151
  if (this._driverInfo.isMobile) {
149
- (_j = (_u = this._driverInfo).platformName) !== null && _j !== void 0 ? _j : (_u.platformName = userAgentInfo.platformName);
150
- (_k = (_v = this._driverInfo).platformVersion) !== null && _k !== void 0 ? _k : (_v.platformVersion = userAgentInfo.platformVersion);
152
+ (_j = (_v = this._driverInfo).platformName) !== null && _j !== void 0 ? _j : (_v.platformName = userAgentInfo.platformName);
153
+ (_k = (_w = this._driverInfo).platformVersion) !== null && _k !== void 0 ? _k : (_w.platformVersion = userAgentInfo.platformVersion);
151
154
  }
152
155
  else {
153
156
  this._driverInfo.platformName = (_l = userAgentInfo.platformName) !== null && _l !== void 0 ? _l : this._driverInfo.platformName;
154
157
  this._driverInfo.platformVersion = (_m = userAgentInfo.platformVersion) !== null && _m !== void 0 ? _m : this._driverInfo.platformVersion;
155
158
  }
156
159
  }
157
- (_o = (_w = this._driverInfo).features) !== null && _o !== void 0 ? _o : (_w.features = {});
158
- (_p = (_x = this._driverInfo.features).allCookies) !== null && _p !== void 0 ? _p : (_x.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
160
+ (_o = (_x = this._driverInfo).features) !== null && _o !== void 0 ? _o : (_x.features = {});
161
+ (_p = (_y = this._driverInfo.features).allCookies) !== null && _p !== void 0 ? _p : (_y.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
159
162
  }
160
163
  else {
161
164
  const barsHeight = await ((_r = (_q = this._spec).getBarsHeight) === null || _r === void 0 ? void 0 : _r.call(_q, this.target).catch(() => undefined));
@@ -201,6 +204,9 @@ class Driver {
201
204
  ? await helper_ios_1.HelperIOS.make({ spec: this._spec, driver: this, logger: this._logger })
202
205
  : await helper_android_1.HelperAndroid.make({ spec: this._spec, driver: this, logger: this._logger });
203
206
  }
207
+ if (this.isMobile) {
208
+ (_s = (_z = this._driverInfo).orientation) !== null && _s !== void 0 ? _s : (_z.orientation = await this.getOrientation().catch(() => undefined));
209
+ }
204
210
  this._logger.log('Combined driver info', this._driverInfo);
205
211
  return this;
206
212
  }
@@ -390,8 +396,11 @@ class Driver {
390
396
  return this.currentContext.execute(script, arg);
391
397
  }
392
398
  async takeScreenshot() {
393
- const data = await this._spec.takeScreenshot(this.target);
394
- return utils.types.isString(data) ? data.replace(/[\r\n]+/g, '') : data;
399
+ const image = await this._spec.takeScreenshot(this.target);
400
+ if (utils.types.isString(image)) {
401
+ return Buffer.from(image.replace(/[\r\n]+/g, ''), 'base64');
402
+ }
403
+ return image;
395
404
  }
396
405
  async getViewportSize() {
397
406
  var _a;
@@ -459,13 +468,13 @@ class Driver {
459
468
  throw new Error('Failed to set viewport size!');
460
469
  }
461
470
  async getDisplaySize() {
462
- if (this.isWeb)
471
+ if (this.isWeb && !this.isMobile)
463
472
  return;
464
473
  const size = await this._spec.getWindowSize(this.target);
465
474
  return this.isAndroid ? utils.geometry.scale(size, 1 / this.pixelRatio) : size;
466
475
  }
467
476
  async getOrientation() {
468
- if (this.isWeb)
477
+ if (this.isWeb && !this.isMobile)
469
478
  return;
470
479
  const orientation = this._spec.getOrientation(this.target);
471
480
  this._logger.log('Extracted device orientation:', orientation);
package/dist/element.js CHANGED
@@ -289,6 +289,7 @@ class Element {
289
289
  if (this.driver.isAndroid) {
290
290
  remainingOffset = utils.geometry.scale(remainingOffset, this.driver.pixelRatio);
291
291
  }
292
+ const actions = [];
292
293
  const touchPadding = await this.getTouchPadding();
293
294
  const xPadding = Math.max(Math.floor(effectiveRegion.width * 0.1), touchPadding);
294
295
  const yTrack = Math.floor(effectiveRegion.y + effectiveRegion.height / 2); // center
@@ -299,7 +300,7 @@ class Element {
299
300
  while (xRemaining > 0) {
300
301
  const xRight = effectiveRegion.x + Math.min(xRemaining + xPadding, effectiveRegion.width - xPadding);
301
302
  const [xStart, xEnd] = xDirection === 'right' ? [xRight, xLeft] : [xLeft, xRight];
302
- await this._spec.performAction(this.driver.target, [
303
+ actions.push([
303
304
  { action: 'press', y: yTrack, x: xStart },
304
305
  { action: 'wait', ms: 100 },
305
306
  { action: 'moveTo', y: yTrack, x: xStart + xGap },
@@ -320,7 +321,7 @@ class Element {
320
321
  while (yRemaining > 0) {
321
322
  const yTop = Math.max(yBottom - yRemaining, effectiveRegion.y + yPadding);
322
323
  const [yStart, yEnd] = yDirection === 'down' ? [yBottom, yTop] : [yTop, yBottom];
323
- await this._spec.performAction(this.driver.target, [
324
+ actions.push([
324
325
  { action: 'press', x: xTrack, y: yStart },
325
326
  { action: 'wait', ms: 100 },
326
327
  { action: 'moveTo', x: xTrack, y: yStart + yGap },
@@ -332,6 +333,15 @@ class Element {
332
333
  ]);
333
334
  yRemaining -= yBottom - yTop;
334
335
  }
336
+ // ios actions should be executed one-by-one sequentially, otherwise the result isn't stable
337
+ if (this.driver.isIOS) {
338
+ for (const action of actions) {
339
+ await this._spec.performAction(this.driver.target, action);
340
+ }
341
+ }
342
+ else {
343
+ await this._spec.performAction(this.driver.target, [].concat(...actions));
344
+ }
335
345
  const actualScrollableRegion = await this.getClientRegion();
336
346
  this._state.scrollOffset = utils.geometry.offsetNegative(requiredOffset, {
337
347
  x: scrollableRegion.x - actualScrollableRegion.x,
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
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;
22
+ exports.visit = exports.getTitle = exports.getUrl = exports.getOrientation = 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
23
  const utils = __importStar(require("@applitools/utils"));
24
24
  function isDriver(driver) {
25
25
  return driver && driver.constructor.name === 'MockDriver';
@@ -86,6 +86,10 @@ async function setWindowSize(driver, size) {
86
86
  await driver.setWindowRect(size);
87
87
  }
88
88
  exports.setWindowSize = setWindowSize;
89
+ async function getOrientation(_driver) {
90
+ return 'portrait';
91
+ }
92
+ exports.getOrientation = getOrientation;
89
93
  async function getUrl(driver) {
90
94
  if (this._isNative)
91
95
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.4.2",
3
+ "version": "1.4.6",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
@@ -73,9 +73,9 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "@applitools/snippets": "2.1.8",
77
- "@applitools/types": "1.0.22",
78
- "@applitools/utils": "1.2.4"
76
+ "@applitools/snippets": "2.1.11",
77
+ "@applitools/types": "1.0.23",
78
+ "@applitools/utils": "1.2.5"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@applitools/sdk-release-kit": "0.13.4",
package/types/driver.d.ts CHANGED
@@ -32,6 +32,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
32
32
  get browserName(): string;
33
33
  get browserVersion(): string | number;
34
34
  get userAgent(): string;
35
+ get orientation(): 'portrait' | 'landscape';
35
36
  get pixelRatio(): number;
36
37
  get statusBarHeight(): number;
37
38
  get navigationBarHeight(): number;
@@ -54,7 +55,7 @@ export declare class Driver<TDriver, TContext, TElement, TSelector> {
54
55
  element(selector: types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>>;
55
56
  elements(selector: types.Selector<TSelector>): Promise<Element<TDriver, TContext, TElement, TSelector>[]>;
56
57
  execute(script: ((arg: any) => any) | string, arg?: any): Promise<any>;
57
- takeScreenshot(): Promise<Buffer | string>;
58
+ takeScreenshot(): Promise<Buffer>;
58
59
  getViewportSize(): Promise<types.Size>;
59
60
  setViewportSize(size: types.Size): Promise<void>;
60
61
  getDisplaySize(): Promise<types.Size>;
@@ -24,6 +24,7 @@ export declare function takeScreenshot(driver: Driver): Promise<Buffer | string>
24
24
  export declare function getDriverInfo(driver: Driver): Promise<DriverInfo>;
25
25
  export declare function getWindowSize(driver: Driver): Promise<Size>;
26
26
  export declare function setWindowSize(driver: Driver, size: Size): Promise<void>;
27
+ export declare function getOrientation(_driver: Driver): Promise<'portrait' | 'landscape'>;
27
28
  export declare function getUrl(driver: Driver): Promise<string>;
28
29
  export declare function getTitle(driver: Driver): Promise<string>;
29
30
  export declare function visit(driver: Driver, url: string): Promise<void>;