@percy/webdriver-utils 1.27.0-beta.1 → 1.27.0
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
|
@@ -31,12 +31,16 @@ export default class WebdriverUtils {
|
|
|
31
31
|
}
|
|
32
32
|
async automateScreenshot() {
|
|
33
33
|
try {
|
|
34
|
+
const startTime = Date.now();
|
|
34
35
|
this.log.info(`[${this.snapshotName}] : Starting automate screenshot ...`);
|
|
35
36
|
const automate = ProviderResolver.resolve(this.sessionId, this.commandExecutorUrl, this.capabilities, this.sessionCapabilites, this.clientInfo, this.environmentInfo, this.options, this.buildInfo);
|
|
36
37
|
this.log.debug(`[${this.snapshotName}] : Resolved provider ...`);
|
|
37
38
|
await automate.createDriver();
|
|
38
39
|
this.log.debug(`[${this.snapshotName}] : Created driver ...`);
|
|
39
|
-
|
|
40
|
+
const comparisonData = await automate.screenshot(this.snapshotName, this.options);
|
|
41
|
+
comparisonData.metadata.cliScreenshotStartTime = startTime;
|
|
42
|
+
comparisonData.metadata.cliScreenshotEndTime = Date.now();
|
|
43
|
+
return comparisonData;
|
|
40
44
|
} catch (e) {
|
|
41
45
|
this.log.error(`[${this.snapshotName}] : Error - ${e.message}`);
|
|
42
46
|
this.log.error(`[${this.snapshotName}] : Error Log - ${e.toString()}`);
|
|
@@ -89,14 +89,16 @@ export default class AutomateProvider extends GenericProvider {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
async getTiles(headerHeight, footerHeight, fullscreen) {
|
|
92
|
+
var _responseValue$metada;
|
|
92
93
|
if (!this.driver) throw new Error('Driver is null, please initialize driver with createDriver().');
|
|
93
94
|
log.debug('Starting actual screenshotting phase');
|
|
95
|
+
const dpr = await this.metaData.devicePixelRatio();
|
|
94
96
|
const response = await TimeIt.run('percyScreenshot:screenshot', async () => {
|
|
95
97
|
return await this.browserstackExecutor('percyScreenshot', {
|
|
96
98
|
state: 'screenshot',
|
|
97
99
|
percyBuildId: this.buildInfo.id,
|
|
98
100
|
screenshotType: 'singlepage',
|
|
99
|
-
scaleFactor:
|
|
101
|
+
scaleFactor: dpr,
|
|
100
102
|
options: this.options
|
|
101
103
|
});
|
|
102
104
|
});
|
|
@@ -107,10 +109,11 @@ export default class AutomateProvider extends GenericProvider {
|
|
|
107
109
|
const tiles = [];
|
|
108
110
|
const tileResponse = JSON.parse(responseValue.result);
|
|
109
111
|
log.debug('Tiles captured successfully');
|
|
112
|
+
const windowHeight = (responseValue === null || responseValue === void 0 ? void 0 : (_responseValue$metada = responseValue.metadata) === null || _responseValue$metada === void 0 ? void 0 : _responseValue$metada.window_height) || 0;
|
|
110
113
|
for (let tileData of tileResponse.sha) {
|
|
111
114
|
tiles.push(new Tile({
|
|
112
|
-
statusBarHeight: 0,
|
|
113
|
-
navBarHeight: 0,
|
|
115
|
+
statusBarHeight: tileResponse.header_height || 0,
|
|
116
|
+
navBarHeight: tileResponse.footer_height || 0,
|
|
114
117
|
headerHeight,
|
|
115
118
|
footerHeight,
|
|
116
119
|
fullscreen,
|
|
@@ -118,9 +121,13 @@ export default class AutomateProvider extends GenericProvider {
|
|
|
118
121
|
}));
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
const metadata = {
|
|
125
|
+
windowHeight: Math.ceil(windowHeight * dpr)
|
|
126
|
+
};
|
|
121
127
|
return {
|
|
122
128
|
tiles: tiles,
|
|
123
|
-
domInfoSha: tileResponse.dom_sha
|
|
129
|
+
domInfoSha: tileResponse.dom_sha,
|
|
130
|
+
metadata: metadata
|
|
124
131
|
};
|
|
125
132
|
}
|
|
126
133
|
async browserstackExecutor(action, args) {
|
|
@@ -132,7 +132,8 @@ export default class GenericProvider {
|
|
|
132
132
|
},
|
|
133
133
|
environmentInfo: [...this.environmentInfo].join('; '),
|
|
134
134
|
clientInfo: [...this.clientInfo].join(' '),
|
|
135
|
-
domInfoSha: tiles.domInfoSha
|
|
135
|
+
domInfoSha: tiles.domInfoSha,
|
|
136
|
+
metadata: tiles.metadata || null
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
139
|
|
|
@@ -141,6 +142,14 @@ export default class GenericProvider {
|
|
|
141
142
|
// execute script and return dom content
|
|
142
143
|
return 'dummyValue';
|
|
143
144
|
}
|
|
145
|
+
async getWindowHeight() {
|
|
146
|
+
// execute script and return window height
|
|
147
|
+
return await this.driver.executeScript({
|
|
148
|
+
script: 'return window.innerHeight',
|
|
149
|
+
args: []
|
|
150
|
+
});
|
|
151
|
+
;
|
|
152
|
+
}
|
|
144
153
|
async getTiles(headerHeight, footerHeight, fullscreen) {
|
|
145
154
|
if (!this.driver) throw new Error('Driver is null, please initialize driver with createDriver().');
|
|
146
155
|
const base64content = await this.driver.takeScreenshot();
|
|
@@ -155,7 +164,10 @@ export default class GenericProvider {
|
|
|
155
164
|
fullscreen
|
|
156
165
|
})],
|
|
157
166
|
// TODO: Add Generic support sha for contextual diff for non-automate
|
|
158
|
-
domInfoSha: await this.getDomContent()
|
|
167
|
+
domInfoSha: await this.getDomContent(),
|
|
168
|
+
metadata: {
|
|
169
|
+
windowHeight: await this.getWindowHeight()
|
|
170
|
+
}
|
|
159
171
|
};
|
|
160
172
|
}
|
|
161
173
|
async getTag() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/webdriver-utils",
|
|
3
|
-
"version": "1.27.0
|
|
3
|
+
"version": "1.27.0",
|
|
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.0
|
|
33
|
-
"@percy/sdk-utils": "1.27.0
|
|
32
|
+
"@percy/config": "1.27.0",
|
|
33
|
+
"@percy/sdk-utils": "1.27.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "3b92a894d4cf6dcdedccf42b86aaf61f331535c6"
|
|
36
36
|
}
|