2019-11-25 08:13:20 +00:00
|
|
|
|
2019-12-12 07:37:35 +00:00
|
|
|
import Puppeteer from 'puppeteer';
|
|
|
|
import {extendPage} from './extensions';
|
|
|
|
import {url as defaultURL} from './config';
|
2019-11-25 08:13:20 +00:00
|
|
|
|
2020-01-14 08:20:14 +00:00
|
|
|
export async function getBrowser() {
|
|
|
|
const browser = await Puppeteer.launch({
|
|
|
|
args: [
|
2020-01-23 15:01:29 +00:00
|
|
|
`--window-size=${ 1920 },${ 1080 }`
|
2020-01-14 08:20:14 +00:00
|
|
|
],
|
|
|
|
defaultViewport: null,
|
|
|
|
headless: false,
|
|
|
|
slowMo: 0, // slow down by ms
|
2019-12-12 07:37:35 +00:00
|
|
|
});
|
2020-01-14 08:20:14 +00:00
|
|
|
let page = (await browser.pages())[0];
|
|
|
|
page = extendPage(page);
|
2020-01-23 15:01:29 +00:00
|
|
|
page.setDefaultTimeout(5000);
|
2020-01-14 08:20:14 +00:00
|
|
|
await page.goto(defaultURL, {waitUntil: 'networkidle0'});
|
|
|
|
return {page, close: browser.close.bind(browser)};
|
2019-12-12 07:37:35 +00:00
|
|
|
}
|
2019-11-25 08:13:20 +00:00
|
|
|
|
2020-01-14 08:20:14 +00:00
|
|
|
export default getBrowser;
|