-2

I want to get the Text of a Element with Selenium.

Element:

<p class="sc-168cvuh-1 cNxwvb"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="circle" class="svg-inline--fa fa-circle fa-w-16 fa-fw sc-168cvuh-2 frUsNu" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" _css="[object Object],[object Object]"><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>&nbsp;running</p>

I wanna get the "running" from the Element.

How to do that?

  • 1
    Does this answer your question? [How to get text of an element in Selenium WebDriver, without including child element text?](https://stackoverflow.com/questions/12325454/how-to-get-text-of-an-element-in-selenium-webdriver-without-including-child-ele) – 0stone0 Jun 03 '21 at 16:03
  • can you share what you have tried so far? Are you getting any error? – itronic1990 Jun 03 '21 at 16:05
  • @0stone0 No that didnt work. @ itronic1990 I tiried getting the whole Class by Xpath and than getting the Text with: "statustext.text" – ErsterImChat Jun 03 '21 at 16:08
  • Look at this answer, is really helpful https://stackoverflow.com/questions/67824928/get-text-from-an-element-with-selenium-python – olysses May 22 '22 at 19:48
  • Look at this answer https://stackoverflow.com/questions/67824928/get-text-from-an-element-with-selenium-python – olysses May 22 '22 at 22:03

1 Answers1

1

Does this work ?

wait = WebDriverWait(driver, 10)
desired_text = wait.until(EC.visibility_of_element_located((By.XPATH, "//p[contains(@class, 'sc-')]"))).text
print(desired_text)

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
cruisepandey
  • 26,802
  • 6
  • 16
  • 37