I want to extract the first span
with the text Extract this text
. Already tried:
element.find_element_by_css_selector(".moreContent span:nth-child(1)").text.strip('"')
This is not working, I am not sure why. The output is just empty.
<p class="mainText">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
<span class="moreEllipses">… </span>
<span class="moreContent">
<span> Extract this text </span>
<span class="link moreLink">Show More</span>
</span>
</p>
However I am getting this, so Selenium finds the element but why the output is empty:
<selenium.webdriver.remote.webelement.WebElement (session="e7012b303842651848aa0b0e40f5d5c1", element="df5644e9-fc98-4300-ad86-9ff433154d82")>
EDIT:
I managed to solve this by clicking on show more button. For some reason i can't extract the content if not visible even if present in page.