I am trying to extract urlToBeCaptured
and Text to be captured
from the HTML. The structure looks as follows:
<li>
" text with trailing spaces "
<a href="urlToBeCaptured">
<span class ="class1> Text to be captured </span>
<span class ="class2> Another text </span>
</a>
...
</li>
I am doing the following, but it doesn't seem to work:
el = driver.find_element(By.XPATH, "//li[contains(text(),'text with trailing spaces')]")
Once I locate the element how to extract the text from class1, should it be something like this?
textToBeCaptured = el.find_element(By.CLASS_NAME, 'class1').text