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

186
Vistas
Convert $x()'s return value to individual strings in browser console (one liner)?

How can I convert the return value of an XPath search $x(), when executed in a browser console, to individual strings so that I can perform string manipulations on the result in a "one-liner"?

Imagine that I run a $x() and the result is three values:

abc
def
ghi

I then want to extract the first letter from each of these result, using something like 'abc'.match("."). It has to be a "one-liner" because the purpose is to distribute it to non-technical users that should be able to just copy-paste it into the console.

Error handling is not necessary.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This Google Chrome console one-liner,

$x('//span').map(e => e.textContent.charAt(0))

will return an array of the first characters of the text content of every span element of the current page. Update the XPath side (//span) or the JavaScript side (.map(e => e.textContent.charAt(0)))) as needed for your particular case.

about 4 years ago · Santiago Trujillo 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