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

137
Visualizações
How to Click a Span Without a Name or ID

I'm trying to use Pupeteer to respond to a popup dialog box, but can't find a way to click the OK button which is just an image inside a <span>

This is what I've tried so far:

  const [button] = await frame.$x('/html/body/div/div[4]/div[2]/div/span[1]');
  
  if (button) {
       await button.click()
  }

But the button is not found.

This is the pertinent section of the html:

   <div class="vtm_text vtm_exportDialog"><input type="hidden" value="save">
      ...
      <span class="vtmBtn" style="min-width: 60px; padding: 3px;">OK</span>
      <span class="vtmBtn" style="min-width: 60px; padding: 3px;">Cancel</span>
    </div>

This is what the page looks like when inspected in Chrome:

This is what the page looks like when inspected in Chrome

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

const [button] = await frame.$x("/html/body/div/div[4]/div[2]/div/span[1]");

async function pop_up() {
  if (button) {
    await button.click();
  }
}

document.getElementsByClassName("vtmBtn").addEventListener("click", (e) => {
  var img = document.createElement("img");
  img.setAttribute("src", "");
  //   in the empty string put the path of the image you want

  e.target.appendChild(img);
});
about 4 years ago · Juan Pablo Isaza Relatório

0

I was able to solve this by using $eval as follows:

await frame.$eval('span[class=vtmBtn]', el => el.click());
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