47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
|
|
const { chromium } = require('playwright');
|
||
|
|
const fs = require('fs');
|
||
|
|
|
||
|
|
async function run() {
|
||
|
|
const browser = await chromium.launch();
|
||
|
|
const context = await browser.newContext();
|
||
|
|
const page = await context.newPage();
|
||
|
|
|
||
|
|
try {
|
||
|
|
const loginUrl = process.env.LIVE_SITE_LOGIN_URL;
|
||
|
|
const raceUrl = process.env.LIVE_SITE_RACE_URL;
|
||
|
|
|
||
|
|
console.log('--- Step 1: Navigating to Login ---');
|
||
|
|
await page.goto(loginUrl, { waitUntil: 'load' });
|
||
|
|
|
||
|
|
console.log('--- Step 2: Filling credentials ---');
|
||
|
|
await page.type('#login', process.env.LIVE_SITE_USERNAME);
|
||
|
|
await page.type('#pwd', process.env.LIVE_SITE_PASSWORD);
|
||
|
|
|
||
|
|
console.log('--- Step 3: Clicking Accedi ---');
|
||
|
|
await page.click('button:has-text("Accedi")');
|
||
|
|
await page.waitForTimeout(5000); // Give it time to process and redirect
|
||
|
|
|
||
|
|
console.log('--- Step 4: Navigating to Race Page ---');
|
||
|
|
const response = await page.goto(raceUrl, { waitUntil: 'load' });
|
||
|
|
|
||
|
|
console.log('Race Page URL:', page.url());
|
||
|
|
console.log('HTTP Status:', response.status());
|
||
|
|
|
||
|
|
const cookies = await context.cookies();
|
||
|
|
const cookieNames = cookies.map(c => c.name);
|
||
|
|
console.log('Cookies:', cookieNames.join(', '));
|
||
|
|
console.log('rus_faceai_identity:', cookieNames.includes('rus_faceai_identity'));
|
||
|
|
console.log('JSESSIONID:', cookieNames.includes('JSESSIONID'));
|
||
|
|
|
||
|
|
const logoutCount = await page.locator('a[href*="logout"]').count();
|
||
|
|
const loginCount = await page.locator('a[href*="login"]').count();
|
||
|
|
console.log('Logout Link Count:', logoutCount);
|
||
|
|
console.log('Login Link Count:', loginCount);
|
||
|
|
|
||
|
|
} catch (err) {
|
||
|
|
console.error('Error occurred:', err.message);
|
||
|
|
} finally {
|
||
|
|
await browser.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
run();
|