Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
workflow.url = getUrl(workflow);
const options: BrowserCreateOptions = { size: workflow.size };
if (CONFIG.domPath) options.domPath = `${CONFIG.domPath}/${workflow.name}`;
self._browser = await Browser.create(options);
self._envValues = getEnvValues(workflow);
self._workflow = workflow;
if (CONFIG.videoPath) {
const device = self._browser.device;
self._screenCapture = await ScreenCapture.start({
offset: {
x: CONFIG.chromeOffsetX,
y: CONFIG.chromeOffsetY
},
savePath: `${CONFIG.videoPath}/${workflow.name}`,
size: {
height: device.viewport.height,
width: device.viewport.width
}
});
}
try {
await self._browser.goto(workflow.url);
} catch (error) {
logger.error(`Runner: could not goto ${workflow.url}: ${error}`);
// finish the video
await self.close();
browser.scroll = qawolf.scroll.bind(qawolf);
browser.select = qawolf.select.bind(qawolf);
browser.type = qawolf.type.bind(qawolf);
browser.qawolf = qawolf;
await managePages(browser);
if (options.url) await qawolf.goto(options.url);
const videoPath = options.videoPath || CONFIG.videoPath;
if (videoPath) {
// start capture after goto
qawolf._screenCapture = await ScreenCapture.start({
offset: {
x: CONFIG.chromeOffsetX,
y: CONFIG.chromeOffsetY
},
savePath: `${CONFIG.videoPath}/${basename(require.main!.filename)}`,
size: {
height: device.viewport.height,
width: device.viewport.width
}
});
}
return browser;
};
const buildPuppeteerOptions = (
options: PuppeteerLaunchOptions,
device: Device
) => {
const launchOptions: PuppeteerLaunchOptions = {
args: [
"--disable-dev-shm-usage",
"--no-default-browser-check",
"--window-position=0,0",
`--window-size=${device.viewport.width + CONFIG.chromeOffsetX},${device
.viewport.height + CONFIG.chromeOffsetY}`
],
defaultViewport: null,
headless: CONFIG.headless,
...options
};
if (platform() === "linux") {
launchOptions!.args!.push("--disable-gpu");
launchOptions!.args!.push("--disable-setuid-sandbox");
launchOptions!.args!.push("--no-sandbox");
}
if (CONFIG.chromeExecutablePath) {
launchOptions.executablePath = CONFIG.chromeExecutablePath;
}