1

I have been using this function https://stackoverflow.com/a/48267887/11220889 for waiting for downloads to finish and returning the file path once finished. And it has been working great until now.

The Function

def every_downloads_chrome(driver):
    if not driver.current_url.startswith("chrome://downloads"):
        driver.get("chrome://downloads/")
    return driver.execute_script('''
        var items = downloads.Manager.get().items_;
        if (items.every(e => e.state === "COMPLETE"))
            return items.map(e => e.file_url);
        ''')

How its called

paths = WebDriverWait(driver, 120, 1).until(every_downloads_chrome)

Error I'm receiving

TypeError: 'NoneType' object is not subscriptable

So from what I can gather something has changed that has started causing the function to not return a path. I believe this is due to a change within chrome or even more specifically the chrome driver. My two reasons for this assumption is:

1) I had this function in another code that my colleague was using and she called me saying it was producing this error yesterday.

2)Neither code has changed so the change must be in chrome

I would like to keep using this script but if not possible have another function that waits for the downloads to finish and returns the paths and ideally does it all through the driver not through file path since multiple users use my codes on multiple machines.

EDIT: Versions-

Name: selenium
Version: 3.141.0

Name: Chrome Browser
Version: 73.0.3683.86

Name: Chrome Driver
Version: 2.43.600210

Name: System
Version: Windows 10 Pro x64
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
AG-W
  • 70
  • 1
  • 10

1 Answers1

2

As per the error message:

TypeError: 'NoneType' object is not subscriptable

Your main issue seems to be incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.43
  • Release Notes of chromedriver=2.43 clearly mentions the following :

Supports Chrome v69-71

  • You are using chrome=73.0
  • Release Notes of ChromeDriver v2.46 clearly mentions the following :

Supports Chrome v71-73

So there is a clear mismatch between ChromeDriver v2.43 and the Chrome Browser v73.0


Solution

  • Upgrade ChromeDriver to current ChromeDriver v2.46 level.
  • Keep Chrome version at Chrome v73 level. (as per ChromeDriver v2.46 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
  • Execute your @Test.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Update

Currently GAed Chrome v73 have some issues and you may like to downgrade to Chrome v72. You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    First, thank you for your answer. I have updated the driver and am still experiencing the error so as per your suggestion what exactly do you mean by rebuild with required dependencies only? – AG-W Mar 28 '19 at 14:33
  • @AG-W Checkout my updated answer and let me know the status. – undetected Selenium Mar 28 '19 at 14:51