Skip to content

Instantly share code, notes, and snippets.

@eliseodm
Created September 10, 2021 22:27
Show Gist options
  • Save eliseodm/c09177cbe1c10ab0a3c5a7e8e2c543f8 to your computer and use it in GitHub Desktop.
Save eliseodm/c09177cbe1c10ab0a3c5a7e8e2c543f8 to your computer and use it in GitHub Desktop.
onst puppeteer = require('puppeteer');
const username = '58050';
const password = 'toro';
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
/* page.setViewport({
width: 1280,
height: 800,
isMobile: false
}) */
// Espera hasta que la pagina este cargada
await page.goto('http://138.219.43.212:8084/cmedico/index.jsp', { waitUntil: 'networkidle0'});
// Espera hasta que cargue los elementos seleccionados
await Promise.all([
page.waitForSelector('input[type="text"]'),
page.waitForSelector('input[type="password"]'),
page.waitForSelector('span[id="button-1014-btnInnerEl"]')
]);
//Ingresa usuario y contrasegna
await page.type('[type="text"]', username, { delay: 25 });
await page.type('[type="password"]', password, { delay: 25 });
// Clickea en el imput del logIN, espera a cargar la pagina
await page.click('span[id="button-1014-btnInnerEl"]', { waitUntil: 'networkidle0'});
// Espera hasta que cargue el primer nivel + 'CMT' despliegue y lo clickea, primer nivel de la tabla
await page.waitForSelector('tr[id="treeview-1036-record-0"]');
await page.click('tr[id="treeview-1036-record-0"]', { delay: 25 });
// Espera hasta que cargue el segundo nivel 'Medico' despliegue y lo clickea
await page.waitForSelector('tr[id="treeview-1036-record-1002"]');
await page.click('tr[id="treeview-1036-record-1002"]', { delay: 25 });
await page.click('tr[id="treeview-1036-record-1002"]', { delay: 25 });
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment