2

I am having trouble getting the text element ("1,028 Sales") from the following page: https://www.etsy.com/shop/susansimonini?ref=l2-shopheader-name.

I can get the element itself with no issue using this:

driver.find_element_by_class_name('shop-sales') 

But I cannot convert it to text. The following results in a blank line:

sales=driver.find_element_by_class_name('shop-sales').text
print sales

What am I doing wrong? Thanks in advance for your help.

josh

1 Answer 1

2

The .text returns an empty string because the targeted element is hidden. So you can either target the visible one holding the sales count :

text = driver.find_element_by_css_selector(".shop-info .shop-location + span").text

Or you could directly get the innerHTML or textContent property :

text = driver.find_element_by_css_selector(".shop-sales").get_attribute("textContent")
text = driver.find_element_by_css_selector(".shop-sales").get_attribute("innerHTML")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.