Python Selenium: Firefox set_preference to overwrite files on download? Python Selenium: Firefox set_preference to overwrite files on download? selenium selenium

Python Selenium: Firefox set_preference to overwrite files on download?


This is something that is out of the Selenium's scope and is handled by the operating system.

Judging by the context of this and your previous question, you know (or can determine from the link text) the filename beforehand. If this is really the case, before hitting the "download" link, make sure you remove the existing file:

import osfilename = "All-tradable-ETFs-ETCs-and-ETNs.xlsx"  # or extract it dynamically from the linkfilepath = os.path.join(dl_dir, filename)if os.path.exists(filepath):    os.remove(filepath)