How do I find the element with text “Jessica” based on “3000” displaying in the web page using xpath?
I’m getting …not a valid xpath error.
<div>
<span><b>Jessica</b></span>
<br>
<label>Total Wealth ($):</label>
<p>3000</p>
</div>
I tried this
RichestPersonName = browser.find_element_by_xpath(“//p[text()=’3000′] .. /span”).text
but it shows
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression //p[text()=’3000′] .. /span because of the following error:
SyntaxError: Failed to execute ‘evaluate’ on ‘Document’: The string ‘//p[text()=’3000′] .. /span’ is not a valid XPath expression.
Source: Read More