I’m trying to download a pdf at the following link:
https://www.cms.gov/medicare-coverage-database/view/lcd.aspx?lcdid=39763&ver=8
Most documents at this website have the a pop up for accepting a license which I can close using
driver.find_element(By.ID, "btnAcceptLicense").click()
The link above has another pop up afterward that contains a “close” button. I can find with
elem = driver.find_element(By.CLASS_NAME, "modal-footer").find_element(By.CLASS_NAME, "btn")
But when I run elem.click()
, I get a ElementNotInteractableException
.
Here is what I’ve written so far:
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)
url = "https://www.cms.gov/medicare-coverage-database/view/lcd.aspx?lcdid=39859&ver=4"
driver.get(url)
time.sleep(0.5)
# Accept license
driver.find_element(By.ID, "btnAcceptLicense").click()
time.sleep(0.5)
# Close pop second pop up (fails here)
driver.find_element(By.CLASS_NAME, "modal-footer").find_element(By.CLASS_NAME, "btn").click()
# Download document
driver.find_element(By.ID, "btnDownload").click()