Forums

Issue with Button Clickability in Selenium

I am trying to scrape some data from a website, and it just can't find the button that I want to interact with. This is the website that I am working with: https://www.cboe.com/tradable_products/vix/term_structure/

"""Some code above"""

def scrape_data(date_value, time_value='3:14 PM'):
# Interacting with the website
wait = WebDriverWait(driver, 10)

date_picker_1 = wait.until(EC.presence_of_element_located((By.ID, "dateInput_1")))
date_picker_1.clear()
date_picker_1.send_keys(date_value)
print('dateInput_1 successful')

date_picker_2 = wait.until(EC.presence_of_element_located((By.ID, "dateInput_2")))
date_picker_2.clear()
date_picker_2.send_keys(time_value)
print('dateInput_2 successful')

button = wait.until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(), "Get Index Value")]')))
button.click()
print('button_click successful')

try:
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "/html/body/main/section[2]/div/div/div/div/div[4]/table/tbody"))
    )
    data_element = driver.find_element(By.XPATH, "/html/body/main/section[2]/div/div/div/div/div[4]/table/tbody")
    scraped_data = data_element.text
except TimeoutException:
    scraped_data = 'No data'
finally:
    driver.quit()
return scraped_data

"""Some code below"""

I've already tried different methods by full XPATH (not finding via text as shown above). The thing is By.ID works just fine with dateInputs 1 and 2. However I do not have a unique ID for the button to use By.ID

This is the error it throws:

url loaded successfully
bot created succesfully
dateInput_1 successful
dateInput_2 successful
Traceback (most recent call last):
  File "/home/dan06ial/sp_predictor_webscraper/main.py", line 170, in <module>
    check_and_notify(yesterday_date)
  File "/home/dan06ial/sp_predictor_webscraper/main.py", line 142, in check_and_notify
    scraped_data = scrape_data(date)
  File "/home/dan06ial/sp_predictor_webscraper/main.py", line 47, in scrape_data
    button.click()
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 81, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 740, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <span class="Button__TextContainer-cui__sc-1ahwe65
-1 efJYwi">...</span> is not clickable at point (414, 293). Other element would receive the click: <div class="cky-notice">...</div>
  (Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x59d6597bfe89 <unknown>

Please someone help me

And BTW: Python 3.10.5 Selenium 4.1.5

I'd recommend using the driver.get_screenshot_as_file method to see what the page looks like at the point where it's in that unexpected state -- perhaps by looking at the page you'll be able to see what is wrong.