WebDriverWait.until - javascript error: Cannot read property 'get' of undefined

后端 未结 1 2002
无人及你
无人及你 2021-01-16 02:45

I have a function to access a website and export some Excel file. For that, I import from selenium:

from selenium.webdriver.support.ui import WebDriverWait
<         


        
1条回答
  •  迷失自我
    2021-01-16 03:30

    The problem: downloads.Manager.get() doesn't work after version 80 of Chrome.

    So, I chang# method to get the downloaded file name

    def every_downloads_chrome(driver):
        if not driver.current_url.startswith("chrome://downloads"):
            driver.execute_script("window.open('');")
            driver.switch_to.window(driver.window_handles[1])
            driver.get("chrome://downloads/")
        return driver.execute_script("""
            var elements = document
            .querySelector('downloads-manager')
            .shadowRoot.querySelector('#downloadsList').items;
            if (elements.every(e => e.state === "COMPLETE"))
                   return elements.map(elements =>elements.fileUrl || elements.file_url);
            """)
    

    0 讨论(0)
提交回复
热议问题