from selenium import webdriver
import os
cwd = os.getcwd()
driver = webdriver.Chrome(cwd+'/chromedriver')
driver.get('site_url')
all_spans=driver.find_elements_by_xpath("//span[@class='Practice_Question_Body']")
for span in all_spans:
textHtml =span.get_attribute('innerHTML')
Try below xpath:
wait = WebDriverWait(driver, 10)
element =wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='Practice_Question_Body'][contains(.,'What is the purpose of')]")))
Note: please add below imports to your solution
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
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.