Navigating chrome://downloads/ page using Python Selenium

Viewed 79

I am trying to click on the first download in my chrome://downloads/ webpage using Python and the Selenium Chromedriver. Any suggestions on how to navigate through the Shadow DOMs using Python to access this download. Thanks!

1 Answers

You can use execute_script. For example, this code return name of the last downloaded file:

driver.execute_script("""
                var file_name = document.querySelector('downloads-manager')
                    .shadowRoot.getElementById('frb0')
                    .shadowRoot.getElementById('file-link').textContent;
                return file_name;
                """)
Related