[Python] How to handle elements inside Shadow DOM from Selenium

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    I want to automate file download completion checking in chromedriver. HTML of each entry in downloads list looks like

    <a is="action-link" id="file-link" tabindex="0" role="link" href="http://fileSource" class="">DownloadedFile#1</a>


    So I use following code to find target elements:

    driver.get('chrome://downloads/') # This page should be available for everyone who use Chrome browser
    driver.find_elements_by_tag_name('a')


    This returns empty list while there are 3 new downloads.

    As I found out, only parent elements of #shadow-root (open) tag can be handled. So How can I find elements inside this #shadow-root element?

    Continue reading...

Compartilhe esta Página