-
Notifications
You must be signed in to change notification settings - Fork 1
/
allianz-example.js
49 lines (38 loc) · 996 Bytes
/
allianz-example.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import puppeteer from 'puppeteer';
import {
login,
logout,
getSummary,
} from './allianz.js';
const {
ALLIANZ_USERNAME,
ALLIANZ_PASSWORD,
ALLIANZ_SECURITY_IMAGE_SUBSTR,
PUPPETEER_HEADLESS = 'true',
} = process.env;
async function main() {
if (!ALLIANZ_USERNAME) {
console.error(`ALLIANZ_USERNAME was not set!`);
process.exit(1);
}
if (!ALLIANZ_PASSWORD) {
console.error(`ALLIANZ_PASSWORD was not set!`);
process.exit(1);
}
if (!ALLIANZ_SECURITY_IMAGE_SUBSTR) {
console.error(`ALLIANZ_SECURITY_IMAGE_SUBSTR was not set!`);
process.exit(1);
}
const browser = await puppeteer.launch({
headless: PUPPETEER_HEADLESS === 'true',
});
const page = await browser.newPage();
await login(page, ALLIANZ_USERNAME, ALLIANZ_PASSWORD, ALLIANZ_SECURITY_IMAGE_SUBSTR);
const summary = await getSummary(page);
console.log('Allianz summary:', summary);
await logout(page);
await browser.close();
}
(async () => {
await main();
})();