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!