Reputation: 69
Im trying to access the highlighted image but am having trouble I have tried the XPATH and CSS SELECTOR but neither seem to be working. Using Selenium w python & chrome btw
Upvotes: 0
Views: 91
Reputation: 179
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')
Upvotes: 2
Reputation: 4177
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
Upvotes: 1