-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (41 loc) · 1.68 KB
/
index.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 { firefox } from 'playwright';
import { accounts, username, password } from './config/index.js';
import { loginService } from './src/services/loginService.js';
import { nextStory, pauseStory } from './src/constants/selectors.js';
import { countStories } from './src/workflows/storyCounter.js';
import { profileService } from './src/services/profileService.js';
import { checkForStories } from './src/workflows/checkForStories.js';
import { navigateToFirstStory } from './src/workflows/navigateToFirstStory.js';
import { takeScreenshot } from './src/workflows/takeScreenshot.js';
const storiesScreenshot = async () => {
// Configuración de Playwright
const browser = await firefox.launch({ headless: true });
const context = await browser.newContext({ locale: 'es-ES' });
const page = await context.newPage();
// Inicio de sesión
await loginService(page, username, password);
// Recorrido de las cuentas
for (const account of accounts) {
await profileService(page, account);
if (await checkForStories(page)) {
await countStories(page, account);
await navigateToFirstStory(page);
let storyNumber = 1;
await takeScreenshot(page, account, storyNumber);
while ((await page.locator(nextStory).count()) > 0) {
await page.locator(nextStory).click();
await page.waitForTimeout(2000);
storyNumber++;
await page.locator(pauseStory).click();
await takeScreenshot(page, account, storyNumber);
}
} else {
console.log('Account:', account.username);
console.log('No story');
console.log('==================');
}
}
// Cierre del navegador
await browser.close();
};
storiesScreenshot();