@percy/webdriver-utils 1.27.4-beta.3 → 1.27.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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
@@ -47,8 +47,7 @@ export default class AutomateProvider extends GenericProvider {
|
|
|
47
47
|
error = e;
|
|
48
48
|
throw e;
|
|
49
49
|
} finally {
|
|
50
|
-
|
|
51
|
-
await this.percyScreenshotEnd(name, (_response = response) === null || _response === void 0 ? void 0 : (_response$body = _response.body) === null || _response$body === void 0 ? void 0 : _response$body.link, `${error}`);
|
|
50
|
+
await this.percyScreenshotEnd(name, error);
|
|
52
51
|
}
|
|
53
52
|
return response;
|
|
54
53
|
}
|
|
@@ -70,14 +69,15 @@ export default class AutomateProvider extends GenericProvider {
|
|
|
70
69
|
}
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
|
-
async percyScreenshotEnd(name,
|
|
72
|
+
async percyScreenshotEnd(name, error) {
|
|
74
73
|
return await TimeIt.run('percyScreenshotEnd', async () => {
|
|
75
74
|
try {
|
|
75
|
+
var _this$buildInfo;
|
|
76
76
|
await this.browserstackExecutor('percyScreenshot', {
|
|
77
77
|
name,
|
|
78
|
-
percyScreenshotUrl,
|
|
79
|
-
status:
|
|
80
|
-
statusMessage,
|
|
78
|
+
percyScreenshotUrl: (_this$buildInfo = this.buildInfo) === null || _this$buildInfo === void 0 ? void 0 : _this$buildInfo.url,
|
|
79
|
+
status: error ? 'failure' : 'success',
|
|
80
|
+
statusMessage: error ? `${error}` : '',
|
|
81
81
|
state: 'end'
|
|
82
82
|
});
|
|
83
83
|
} catch (e) {
|
|
@@ -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
|
|
3
|
+
"version": "1.27.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "latest"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test:coverage": "yarn test --coverage"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@percy/config": "1.27.4
|
|
33
|
-
"@percy/sdk-utils": "1.27.4
|
|
32
|
+
"@percy/config": "1.27.4",
|
|
33
|
+
"@percy/sdk-utils": "1.27.4"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "bb901bc6aabf20e27528b6cdfab22c9d8721a2b2"
|
|
36
36
|
}
|