Currently, I am working on a web application and testing it with Selenium. Within my code, there is a specific node that I am trying to extract data from.
<span>Profile Run <span class="current">23</span> of 29</span>
My main objective is to retrieve the text "of 29" from this node.
I have attempted utilizing XPath for this task:
//span[contains(text(),'Profile Run')]/text()[last()]
Unfortunately, methods like getAttribute("innerText")
, getAttribute("innerHTML")
, and even getText()
are not producing the desired result.
Upon encountering an error message which states:
The output of the xpath expression //span[contains(text(),'Profile Run')]/text()[last()] is: [object Text]. It should be an element.