0

I would like to get the text inside this specific element here

<div class="comment-text-inner display-inline" data-clipboard-text="free apex coins">free apex coins</div>

How do I get the text from "data-clipboard-text" using python and selenium?

I've tried

comment = driver.find_element_by_xpath("""/html/body/div[3]/div/div[2]/div[2]/div/div/div/div[4]/div[2]/div/div[1]""").text

With no luck

1 Answers1

3

I think you're looking for the method get_attribute().

Essentially, it'd be something like:

driver.find_element_by_xpath(<your xpath>).get_attribute("data-clipboard-text")

Please see this post as well.

clurd
  • 116
  • 1
  • 5
  • He said he wanted the text. I don't think he wants the attribute value (though in this example they are the same). – John Gordon Feb 24 '19 at 17:52
  • 1
    His question specifically states _How do I get the text from "data-clipboard-text" using python and selenium?_ – clurd Feb 24 '19 at 17:54