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

169
Visualizações
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 Respostas
Responde à pergunta

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 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