-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbbva-example.js
52 lines (40 loc) · 1.02 KB
/
bbva-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
50
51
52
import puppeteer from 'puppeteer';
import {
login,
logout,
getSummary,
} from './bbva.js';
const {
BBVA_CARD_NUMBER,
BBVA_PASSWORD,
BBVA_OTP,
PUPPETEER_HEADLESS = 'true',
} = process.env;
async function main() {
if (!BBVA_CARD_NUMBER) {
console.error(`BBVA_CARD_NUMBER was not set!`);
process.exit(1);
}
if (!BBVA_PASSWORD) {
console.error(`BBVA_PASSWORD was not set!`);
process.exit(1);
}
if (!BBVA_OTP) {
console.error(`BBVA_OTP was not set!`);
process.exit(1);
}
const browser = await puppeteer.launch({
headless: PUPPETEER_HEADLESS === 'true',
});
const page = await browser.newPage();
// Set a wide viewport so that all product cards are visible and interaction is simpler
await page.setViewport({ width: 1280, height: 800 });
await login(page, BBVA_CARD_NUMBER, BBVA_PASSWORD, BBVA_OTP);
const summary = await getSummary(page);
console.log('BBVA summary:', summary);
await logout(page);
await browser.close();
}
(async () => {
await main();
})();