2

The browser is FireFox and the language is Python.I am unable to complete the CloudFlare human verification.

In this website(https://chat.openai.com/chat), I'm unable to find the "mark" element by this code:

verify=WebDriverWait(driver, 10,0.1).until(EC.presence_of_element_located((By.CLASS_NAME, 'mark')))

HTML:

enter image description here

Error Message:

Traceback (most recent call last):
  File ,
    verify=WebDriverWait(driver, 10,0.1).until(EC.presence_of_element_located((By.CLASS_NAME, 'mark')))
  File "...Python310\lib\site-packages\selenium\webdriver\support\wait.py", line 90, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.jsm:12:1
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:192:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:404:5
element.find/</<@chrome://remote/content/marionette/element.js:291:16

Why and how to fix it.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
ren
  • 43
  • 5

1 Answers1

0

The element <span class="mark>...</mark> have a visible text in it. So to identify the element instead of presence_of_element_located() you need to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "label.ctp-checkbox-label span.mark")))
    
  • Using XPATH:

    element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//label[@class='ctp-checkbox-label']//span[@class='mark']")))
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352