0

enter image description here

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

2 Answers 2

2
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')

cwd is your directory(obviously i don't know where chromedriver is)

Sign up to request clarification or add additional context in comments.

5 Comments

not working unfortunately, I dont understand keeps giving me no element exception when it should work
if you pass me the link of the site I can find the problem faster
I believe you can solve this link
The link of the site is edgenuity, which is for online school work so i dont believe youll be able to access it
1

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

1 Comment

No it is not working getting this error [code]Traceback (most recent call last): File "<pyshell#47>", line 1, in <module> element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='Practice_Question_Body'][contains(.,'What is the purpose of'"))) File "C:\Users\Dillionb\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: [/code]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.