Skip to content Skip to sidebar Skip to footer

Failed-Path Too Long Error After Downloading Csv File Using ChromeDriver And Chrome Browser Launched By Selenium Through Cygwin In Python

I try to download csv file from the Chrome browser launched by selenium. But Failed- Path too long error happens while downloading csv file. path: C:/s/d/b I change path like be

Solution 1:

Try with double slash for the path name:

C:\d\s\b

Try also setting the driver page downloads option on init of webdriver.

driver.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': "/path/to/download/dir"}}
command_result = driver.execute("send_command", params)

Solution 2:

try set download directory using add_argument

options = Options()
options.add_argument("download.default_directory=C:/s/d/b")
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=options)

Solution 3:

This error message...

Failed-Path Too Long

...implies that the ChromeDriver failed to interact with the (recently) downloaded file.


As per the discussion Wrong error - "Path Too Long" ... Error should be "File Already Open" this issue is observed when the WebDriver instance i.e. the driver tries to use the downloaded file too soon.

Error Snapshot:

Failed-Path Too Long


Solution

Induce some wait between the twp steps of:

  • Downloading the csv file.
  • Using the csv file for the next action.

Solution 4:

I changed the CSV Download path to cygwin's to dom's path, then I succeeded to download csv file.

CSV Download's path

/cygdrive/c/Users/CSV_DOWNLOAD_PATH

C:/Users/CSV_DOWNLOAD_PATH

Many thanks for your replies.


Post a Comment for "Failed-Path Too Long Error After Downloading Csv File Using ChromeDriver And Chrome Browser Launched By Selenium Through Cygwin In Python"