Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda