-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathutils.js
28 lines (24 loc) · 924 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const utils = require('@percy/sdk-utils');
const { Cache } = require('./cache');
class Utils {
static projectType() {
return utils.percy?.type;
}
static async captureAutomateScreenshot(data) {
return await utils.captureAutomateScreenshot(data);
}
static async sessionDetails(page) {
/* It is browser's guid maintained by playwright, considering it is unique for one automate session
will use it to cache the session details */
const browserGuid = page._parent._parent._guid;
let sessionDetails = Cache.getCache(browserGuid, Cache.sessionDetails);
if (!sessionDetails) {
sessionDetails = JSON.parse(await page.evaluate(/* istanbul ignore next */ _ => { }, `browserstack_executor: ${JSON.stringify({ action: 'getSessionDetails' })}`));
Cache.setCache(browserGuid, Cache.sessionDetails, sessionDetails);
}
return sessionDetails;
}
}
module.exports = {
Utils
};