【发布时间】:2020-04-13 19:49:52
【问题描述】:
【问题讨论】:
标签: python selenium google-chrome
【问题讨论】:
标签: python selenium google-chrome
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')
【讨论】:
试试下面的 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')]")))
注意:请在您的解决方案中添加以下导入
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
【讨论】: