I have the DOM element below:
<span class="styles__Content-rlm06o-1 ixoRjG">20.00000000</span>
that I am trying to get the 20.00000000
value from with:
text = driver.find_elements_by_xpath("//*[@class='styles__Content-rlm06o-1 ixoRjG']")[0].text
...
number = float(text)
But Python returns back could not convert string to float: ''
meaning that the 20.00000000
is not being recognized as text. This code has worked on other websites, so maybe this is a website specific thing? Or is there something I'm overlooking?
You can try to get the text of the first element with this xpath
:
el_text = driver.find_element_by_xpath("//span[contains(@class, 'styles__Content-rlm06o-1 ixoRjG')][1]").text
Also, you can use css
selectors with way:
el_text = driver.find_element_by_css_selector(".styles__Content-rlm06o-1.ixoRjG:nth-of-type(1)").text
If text is still empty, make sure you are waiting for the element to become visible and that this element is not inside iframe.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments