Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!