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

163
Vistas
WebdriverIO invalid selector: Unable to locate an element with the xpath expression

I am facing an issue selecting an element by going up the HTML dome with WebdriverIO. Note: It is easy to select the title by text and the h1 tag or by class name, but i don't want to do that.

Instead, i'd like the iframe tag to be my starting point and select it by partial src link text "nba-scores", then go back to the previous div with class="inner" OR to the div with class="main" without selecting it by class name and once i am on the previous div go to the h1 tag and get the text with pageTitle.getText().

When i use:

get pageTitle(){return $("//iframe[contains(@src, 'nba-scores')]/parent::div//h1)")}

I am getting a SyntaxError: SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//iframe[contains(@src, 'nba-scores')]/parent::div//h1)' is not a valid XPath expression.

Here is my HTML dome

<main>
  <div class="main">
    <div class="inner">
       <h1 class="h1class">NBA Scores</h1>
    </div>
    <iframe src="https://xyz/#/nba-scores/view" class="viewscores">
    </iframe>
  </div>
</main>

Any help would be appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You indeed have a syntax error with a stray ) that is not opened and not necessary so change "//iframe[contains(@src, 'nba-scores')]/parent::div//h1)" to "//iframe[contains(@src, 'nba-scores')]/parent::div//h1"

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