<div class="some_class>
<p>
<strong>
some text
</strong>
</p>
</div>
I try to use driver.find_element_by_xpath("xpath to strong tab").text but this print empty string
Could you try printing the textContent Attribute if text is not in view port or is not displayed:
driver.find_element_by_xpath("xpath to strong tab").get_attribute("textContent")
ALso you could try
strong = driver.find_element_by_xpath("xpath to strong tab")
driver.execute_script("arguments[0].scrollIntoView()",strong)
print(strong.text)
This will bring the element into view
There are chances that there are multiple <strong>
tabs in your page.
Try the following:
allStrongs = driver.find_elements_by_xpath("xpath to strong tab")
for aStrong in allStrongs:
print(aStrong.text)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.