92 lines
4.0 KiB
JavaScript
92 lines
4.0 KiB
JavaScript
const { chromium } = require('playwright');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: false });
|
|
const context = await browser.newContext({
|
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
|
});
|
|
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
console.log('Realizando login para exploração...');
|
|
await page.goto('https://viventerisportalcredenciado.topsaudehub.com.br/', { waitUntil: 'networkidle' });
|
|
await page.fill('#usuario', '0005010');
|
|
await page.fill('#senha', 'Cclinic#03');
|
|
await page.click('#login-submit');
|
|
|
|
await page.waitForURL('**/AreaLogada**');
|
|
console.log('Login realizado. Explorando menu...');
|
|
|
|
// Esperar o menu carregar
|
|
await page.waitForTimeout(3000);
|
|
|
|
// Listar menus principais
|
|
const menuNames = ['Tratamento Odontológico', 'Elegibilidade', 'Faturamento', 'Solicitações Diversas'];
|
|
|
|
for (const name of menuNames) {
|
|
console.log(`Clicando no menu: ${name}`);
|
|
try {
|
|
await page.click(`text="${name}"`, { timeout: 2000 });
|
|
await page.waitForTimeout(1000);
|
|
} catch (e) {
|
|
console.log(`Erro ao clicar em ${name}: ${e.message}`);
|
|
}
|
|
}
|
|
|
|
// Tentar clicar em Solicitações Diversas -> Inclusão
|
|
console.log('Navegando em Solicitações Diversas -> Inclusão...');
|
|
try {
|
|
await page.click('text="Solicitações Diversas"');
|
|
await page.waitForTimeout(500);
|
|
await page.click('text="Inclusão"');
|
|
await page.waitForTimeout(2000);
|
|
console.log('URL após clicar em Inclusão:', page.url());
|
|
} catch (e) {
|
|
console.log('Falha ao seguir caminho Inclusão:', e.message);
|
|
}
|
|
|
|
// Listar links com palavras-chave
|
|
const guiaLinks = await page.evaluate(() => {
|
|
const keywords = ['guia', 'sadt', 'consulta', 'externa', 'recebimentos', 'faturamento', 'lote'];
|
|
return Array.from(document.querySelectorAll('a')).map(a => ({
|
|
text: a.innerText.trim(),
|
|
href: a.getAttribute('href')
|
|
})).filter(l => keywords.some(k => l.text.toLowerCase().includes(k)) || keywords.some(k => (l.href || '').toLowerCase().includes(k)));
|
|
});
|
|
|
|
console.log('Links relacionados a guias encontrados:', JSON.stringify(guiaLinks, null, 2));
|
|
|
|
// Listar TODOS os links do DOM para ver os caminhos
|
|
const allLinks = await page.evaluate(() => {
|
|
return Array.from(document.querySelectorAll('a')).map(a => ({
|
|
text: a.innerText.trim().replace(/\n/g, ' '),
|
|
href: a.getAttribute('href'),
|
|
visible: a.offsetParent !== null
|
|
}));
|
|
});
|
|
|
|
console.log('--- TODOS OS LINKS ENCONTRADOS (VISÍVEIS E INVISÍVEIS) ---');
|
|
allLinks.forEach(l => {
|
|
if (l.text && !l.href.includes('void(0)') && !l.href.startsWith('#')) {
|
|
console.log(`[${l.visible ? 'VISÍVEL' : 'OCULTO'}] ${l.text} -> ${l.href}`);
|
|
}
|
|
});
|
|
|
|
// Tirar um "print" da estrutura do menu principal
|
|
const menuStructure = await page.evaluate(() => {
|
|
// Tenta encontrar o container principal do menu (geralmente nav ou ul com classes específicas)
|
|
const nav = document.querySelector('nav, ul.navbar-nav, .sidebar, #menu');
|
|
return nav ? nav.innerText : 'Container de menu não identificado diretamente';
|
|
});
|
|
console.log('Estrutura de texto do menu:', menuStructure);
|
|
|
|
} catch (error) {
|
|
console.error('Erro na exploração:', error);
|
|
} finally {
|
|
console.log('Mantendo aberto para inspeção manual por 60 segundos...');
|
|
await page.waitForTimeout(60000);
|
|
await browser.close();
|
|
}
|
|
})();
|