@percy/webdriver-utils 1.27.4-beta.3 → 1.27.4-beta.4

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/driver.js CHANGED
@@ -10,6 +10,15 @@ export default class Driver {
10
10
  this.executorUrl = executorUrl.includes('@') ? `https://${executorUrl.split('@')[1]}` : executorUrl;
11
11
  this.passedCapabilities = passedCapabilities;
12
12
  }
13
+ static requestPostOptions(command) {
14
+ return {
15
+ method: 'POST',
16
+ headers: {
17
+ 'Content-Type': 'application/json;charset=utf-8'
18
+ },
19
+ body: JSON.stringify(command)
20
+ };
21
+ }
13
22
  async getCapabilites() {
14
23
  return await Cache.withCache(Cache.caps, this.sessionId, async () => {
15
24
  try {
@@ -38,13 +47,7 @@ export default class Driver {
38
47
  if (!command.script.includes('browserstack_executor')) {
39
48
  command.script = `/* percy_automate_script */ \n ${command.script}`;
40
49
  }
41
- const options = {
42
- method: 'POST',
43
- headers: {
44
- 'Content-Type': 'application/json;charset=utf-8'
45
- },
46
- body: JSON.stringify(command)
47
- };
50
+ const options = Driver.requestPostOptions(command);
48
51
  const baseUrl = `${this.executorUrl}/session/${this.sessionId}/execute/sync`;
49
52
  const response = JSON.parse((await request(baseUrl, options)).body);
50
53
  return response;
@@ -60,16 +63,10 @@ export default class Driver {
60
63
  return response.value;
61
64
  }
62
65
  async findElement(using, value) {
63
- const options = {
64
- method: 'POST',
65
- headers: {
66
- 'Content-Type': 'application/json;charset=utf-8'
67
- },
68
- body: JSON.stringify({
69
- using,
70
- value
71
- })
72
- };
66
+ const options = Driver.requestPostOptions({
67
+ using,
68
+ value
69
+ });
73
70
  const baseUrl = `${this.executorUrl}/session/${this.sessionId}/element`;
74
71
  const response = JSON.parse((await request(baseUrl, options)).body);
75
72
  return response.value;
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ export default class WebdriverUtils {
23
23
  const comparisonData = await automate.screenshot(snapshotName, options);
24
24
  comparisonData.metadata.cliScreenshotStartTime = startTime;
25
25
  comparisonData.metadata.cliScreenshotEndTime = Date.now();
26
+ log.debug(`[${snapshotName}] : Comparison Data: ${JSON.stringify(comparisonData)}`);
26
27
  return comparisonData;
27
28
  } catch (e) {
28
29
  log.error(`[${snapshotName}] : Error - ${e.message}`);
@@ -49,7 +49,7 @@ export default class DesktopMetaData {
49
49
  async screenResolution() {
50
50
  return await Cache.withCache(Cache.resolution, this.driver.sessionId, async () => {
51
51
  const data = await this.driver.executeScript({
52
- script: 'return [(window.screen.width * window.devicePixelRatio).toString(), (window.screen.height * window.devicePixelRatio).toString()];',
52
+ script: 'return [parseInt(window.screen.width * window.devicePixelRatio).toString(), parseInt(window.screen.height * window.devicePixelRatio).toString()];',
53
53
  args: []
54
54
  });
55
55
  const screenInfo = data.value;
@@ -168,10 +168,6 @@ export default class AutomateProvider extends GenericProvider {
168
168
  } = await this.metaData.windowSize();
169
169
  const resolution = await this.metaData.screenResolution();
170
170
  const orientation = (_ref = this.metaData.orientation() || automateCaps.deviceOrientation) === null || _ref === void 0 ? void 0 : _ref.toLowerCase();
171
-
172
- // for android window size only constitutes of browser viewport, hence adding nav / status / url bar heights
173
- [this.header, this.footer] = await this.getHeaderFooter(deviceName, osVersion, browserName);
174
- height = this.metaData.device() && (osName === null || osName === void 0 ? void 0 : osName.toLowerCase()) === 'android' ? height + this.header + this.footer : height;
175
171
  return {
176
172
  name: deviceName,
177
173
  osName,
@@ -2,11 +2,6 @@ import utils from '@percy/sdk-utils';
2
2
  import MetaDataResolver from '../metadata/metaDataResolver.js';
3
3
  import Tile from '../util/tile.js';
4
4
  import Driver from '../driver.js';
5
- import Cache from '../util/cache.js';
6
- const {
7
- request
8
- } = utils;
9
- const DEVICES_CONFIG_URL = 'https://storage.googleapis.com/percy-utils/devices.json';
10
5
  const log = utils.logger('webdriver-utils:genericProvider');
11
6
  export default class GenericProvider {
12
7
  clientInfo = new Set();
@@ -132,9 +127,6 @@ export default class GenericProvider {
132
127
  } = await this.metaData.windowSize();
133
128
  const resolution = await this.metaData.screenResolution();
134
129
  const orientation = this.metaData.orientation();
135
- [this.header, this.footer] = await this.getHeaderFooter();
136
- // for android window size only constitutes of browser viewport, hence adding nav / status / url bar heights
137
- height = this.metaData.osName() === 'android' ? height + this.header + this.footer : height;
138
130
  return {
139
131
  name: this.metaData.deviceName(),
140
132
  osName: this.metaData.osName(),
@@ -238,12 +230,4 @@ export default class GenericProvider {
238
230
  }
239
231
  return elementsArray;
240
232
  }
241
- async getHeaderFooter(deviceName, osVersion, browserName) {
242
- // passing 0 as key, since across different pages and tests, this config will remain same
243
- const devicesConfig = await Cache.withCache(Cache.devicesConfig, 0, async () => {
244
- return (await request(DEVICES_CONFIG_URL)).body;
245
- });
246
- let deviceKey = `${deviceName}-${osVersion}`;
247
- return devicesConfig[deviceKey] ? devicesConfig[deviceKey][browserName] ? [devicesConfig[deviceKey][browserName].header, devicesConfig[deviceKey][browserName].footer] : [0, 0] : [0, 0];
248
- }
249
233
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/webdriver-utils",
3
- "version": "1.27.4-beta.3",
3
+ "version": "1.27.4-beta.4",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,8 +29,8 @@
29
29
  "test:coverage": "yarn test --coverage"
30
30
  },
31
31
  "dependencies": {
32
- "@percy/config": "1.27.4-beta.3",
33
- "@percy/sdk-utils": "1.27.4-beta.3"
32
+ "@percy/config": "1.27.4-beta.4",
33
+ "@percy/sdk-utils": "1.27.4-beta.4"
34
34
  },
35
- "gitHead": "e560f5df1637d30722f8d1d7e6eae9cf99ede2dd"
35
+ "gitHead": "4aaa7b217f60ed9ce953fa8c788f4061a7689459"
36
36
  }