So I need to get a particular text in a webpage that contains 200+ lines of text outside a tag or after span tag.
I was able to get the exact xpath,
By outputVersion = By.xpath("//*[@class='output']/text()[contains(.,'TEXT THAT I NEED')]");
By outputVersion = By.xpath("//*[@class='timestamp']/following-sibling::text()[contains(.,'TEXT THAT I NEED')]");
Although it has text()
on the xpath that I have came up with and using this, I'm having org.openqa.selenium.InvalidSelectorException
whenever I use getText(), getAttribute("value") and getAttribute("innerText").
The actual page elements looks likes this
<pre class="output">
<span class="timestamp">time</span>
"TEXT"
<span class="timestamp">time</span>
"TEXT"
.
.
.
.
.
<span class="timestamp">time</span>
"TEXT THAT I NEED"
.
.
.
.
.
</pre>
With that, I need to come up with an xpath excluding text() on it.
Please note that the <span class="timestamp">time</span>
are more than 200+ lines with different texts and are changing from time to time. Also the text that I need is not in a fixed line location so I'm dependent to the contains