forked from pendo-sandbox/pendo-sandbox.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteraction.js
executable file
·35 lines (29 loc) · 979 Bytes
/
interaction.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
29
30
31
32
33
34
35
const puppeteer = require('puppeteer');
const openOpportunities = require('./automation/demoPaths/open-opportunity');
const addAccount = require('./automation/demoPaths/add-account');
const openContacts = require('./automation/demoPaths/open-contacts');
let instance = null;
async function getBrowserInstance () {
if (!instance) {
instance = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });
}
return instance;
}
(async () => {
const browser = await getBrowserInstance();
let pages = await browser.pages();
pages.forEach(async (page) => {
await page.close();
});
setInterval(async () => {
try {
await openOpportunities(browser);
await addAccount(browser);
await openContacts(browser);
} catch (error) {
console.error(error);
await browser.close();
return process.exit(error);
}
}, 120000);
})();