Skip to content
Advertisement

How to specify print location for PDF printing with Selenium

Whatever I do, the files keep getting printed into my Downloads (Windows default) folder, rather than specified folder. I did my research and apparently the savefile.default_directory option should be used rather than download.default_directory but it doesn’t work anyway. I tried removing the trailing \ from the path with no success. This is on a work PC if it makes any difference, Windows 10 machine.

JavaScript

Advertisement

Answer

You have two issues, the first one is that you are setting prefs twice, and since add_experimental_option() is using a dictionary for the options the second setting overrides the first one, and all those settings are actually deleted.

JavaScript

The second issue is the use of raw string r on the path, it evaluates to C:UsersLucasDownloadsECV\\ which is invalid. Either use / rather than "C:/Users/Lucas/Downloads/ECV/" or use \ without r "C:\Users\Lucas\Downloads\ECV\"

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement