Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

443
Visualizações
headless mode playwright not working as inteded

hi I have a problem with my code, when I start my scraping code with playwright on headless mode: true when I reach a waitfornavitagion for a log in the program stops working and I don't know why cause when I start it in headless mode: false; I reach my final destination without errors. here is my code:

function ashScraping() {
  (async () => {
    const browser = await chromium.launch({
      headless: false,
      slowmo: 300,
      timeout: 70000,
      acceptDownloads: true,
    });
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('https://www.thePageImUsing.com/login');
    await page.locator('input[name="txtUserID"]').click();
    await page.locator('input[name="txtUserID"]').fill(`${user}`);
    await page.locator('input[name="txtPassword"]').click();
    await page.locator('input[name="txtPassword"]').fill(`${cont}`);
    await Promise.all([
      page.waitForNavigation(/*{ url: 'https://home.thePageImUsing.com' }*/),
      page.locator('text=login').click()
    ]);
    const [page1] = await Promise.all([
      page.waitForEvent('popup'),
      page.locator('something..something').click()
    ]);
    await page1.locator('input[name="txtShpno"]').click();
    await page1.locator('input[name="txtShpno"]').fill(`${bodega}`);
    await page1.locator('input:has-text("Buscar")').click();
    await Promise.all([
      page.waitForNavigation(/*{ url: 'home.thePageImUsing.com' }*/),
    ]);
    await page.locator('text=Artículos').click();
    await page.locator('text=Artículos').click();
    await page.locator('text=Artículos').click();
    await page.locator('text=Programa de clientes').click();
    await page.locator('#rdoWarehouse_0').check();
    await page.locator('#rdoAvailability_2').check();
    const [download] = await Promise.all([
      page.waitForEvent('download'),
      page.on('dialog', dialog => dialog.accept()),
      await page.locator('#cmdExport').click(),
    ]);
    const path = download.suggestedFilename();
    await download.saveAs(path);
    await context.close();
    await browser.close();
  })();
};

ashScraping();

so I modified some parts of the code for privacy reasons, but the context it's the same. I would welcome any answers that could point me to the error.

right now when I start the software in headless mode: true this is the error:

line 23: waitfornavigation: timeout.
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Can you check instead of wait for navigation: S1: click on url S2: and in next page check any element using wait for selector....

await Promise.all([
    page.click('.ffwHVz'),
    page.waitForSelector('.icon-User-Filled'),
  ]);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda