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

231
Visualizações
How to automatically dismiss a frame-embedded chat in Playwright?

I have been doing Playwright testing for some time on my company's site, and mostly it's gone all right. But we subscribe to Intercom, and it seems to pop up almost randomly, obscuring stuff I want to test. I've tried several ways, and this one seems to work:

this.page.on('frameattached', async (frame) => {
  await new Promise((resolve) => setTimeout(resolve, 500));
  try {
    const dismiss = await frame.waitForSelector('div[aria-label="Dismiss"]');
    if (dismiss) {
      dismiss.click({ timeout: 2000 });
    }
  } catch (_) {
    return Promise.resolve();
  }
  return Promise.resolve();
});

It's pretty clunky, though. I dislike using locators when it seems like ElementHandle would be the way to go, but I cannot figure out the syntax for it. It's easy enough to get the ElementHandle with frame.$(), but then I can't just do a .click() on the result.

Any clues on how to do this without the tedious timeout and try-catch?

about 4 years ago · Juan Pablo Isaza
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