Skip to content Skip to sidebar Skip to footer

SecurityError: Permission Denied To Access Property "document" On Cross-origin Object Error Clicking On Download Link In Iframe Using Selenium Python

I am working on an automation project and I am trying to download a pdf from a website. The website only contains the pdf but the file type of the webpage is HTML. The pdf is displ

Solution 1:

To click on the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using ID:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "download"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#download"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='download']"))).click()
    
  • 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
    

Reference

You can find a detailed discussion in:


Post a Comment for "SecurityError: Permission Denied To Access Property "document" On Cross-origin Object Error Clicking On Download Link In Iframe Using Selenium Python"