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

198
Visualizações
How do I target a button with extra wrapper tag in XPath?

I tried targeting the below, but can't seem to get it to work. The error I get is

Error: Node is either not clickable or not an HTMLElement.

JavaScript

const btn = await page.$x(//button[contains(., 'My Button')])
await btn[0].click()

HTML/XML

<div>
<button>
<translate original="My Button">My Button</translate>
</button>
</div> 
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

If you truly want substring matching (for example, all of "My Button", "Not My Button", and "My Buttonless Shirt"), then use contains() as @Prophet shows.

On the other hand, if you simply want to abstract away whitespace (along with any elements wrapping the targeted text), then use normalize-space():

//button[normalize-space() = 'My Button']

This selects the button element whose space-normalized string value is exactly 'My Button'.

See also

  • How to use XPath contains() for specific text?
  • What does contains() do in XPath?
about 4 years ago · Santiago Gelvez Relatório

0

Instead of

//button[contains(., 'My Button')]

Try

//translate[contains(., 'My Button')]

Or maybe

//*[local-name()='translate' and contains(., 'My Button')]
about 4 years ago · Santiago Gelvez 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