0

How to print value for the class="valueValue-3kA0oJs5" from below snippet, Tried below things but no luck.

<div class="valuesAdditionalWrapper-3BfAIuML">
    <div class="valueItem-3JDGGSt_">
        <div class="valueValue-3kA0oJs5" style="color: rgb(128, 0, 128);">46.2625</div>
    </div>
</div>

Using class name:

driver.find_element_by_class_name("valueValue-3kA0oJs5")

using xpath:

driver.find_element_by_xpath('//*[@class="valueValue-3kA0oJs5"]')

driver.find_element_by_xpath('//div[@class="valueValue-3kA0oJs5"]')

Please help me on this.

Dev
  • 2,739
  • 2
  • 21
  • 34
  • How does the html code of the elements look like. – Arundeep Chohan Apr 11 '21 at 09:02
  • Does this answer your question? [Python + Selenium: I can't get print text from div](https://stackoverflow.com/questions/57936583/python-selenium-i-cant-get-print-text-from-div) – PySaad Apr 11 '21 at 09:15

2 Answers2

0
print(driver.find_element_by_xpath('//div[@class="valueValue-3kA0oJs5"]').text)

Just use .text on the element found.

Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
0

If you want to get text out of element then use text property on the find_element methods

value = driver.find_element_by_xpath('//*[contains(@class, "valueValue")]').text

And if you want to grab the class attribute value of div element

classname = driver.find_element_by_xpath('//*[contains(@class, "valueValue")]').get_attribute('class')
Dev
  • 2,739
  • 2
  • 21
  • 34