0

I specified my webdriver as follows:

chrome_options = webdriver.ChromeOptions()
curr_path = os.getcwd()
prefs = {'download.default_directory': curr_path, 'download.prompt_for_download': False}
chrome_options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(options=chrome_options)

I created a batch file to execute my python file and it works just fine when I manually execute the batch file. It downloads the file normally and drops it into the specified download path. However, when task scheduler executes the batch file, the download is halted by a prompt for a download path.

Is this some quirk of Windows Task Scheduler or is there a better way to go about this?

Devin
  • 21
  • 1
  • Check this https://stackoverflow.com/questions/35331854/downloading-a-file-at-a-specified-location-through-python-and-selenium-using-chr – SeleniumUser Nov 04 '19 at 20:19
  • Hey Rock, thanks for the tip. That is actually the thread I referenced when I wanted to set a download path in the first place. It works when I manually run the script, but not when Windows Task Scheduler runs it. – Devin Nov 04 '19 at 20:58
  • it's probably some kind of path issue... see this post: https://stackoverflow.com/questions/20196049/problems-running-python-script-by-windows-task-scheduler-that-does-pscp/21116923 – pcalkins Nov 04 '19 at 23:58
  • Thanks pcalkins! This actually resolved my issue. – Devin Nov 05 '19 at 17:12

1 Answers1

2

Just in case anybody runs into this problem, pcalkins' reference was where I found the solution written by Erkin Djindjiev:

You can use the windows Task Scheduler, but make sure the "optional" field "Start In" is filled in.

In the Task Scheduler app, add an action that specifies your python file to run "doSomeWork" and fill in the Start in (optional) input with the directory that contains the file.. So for example if you have a python file in:

C:\pythonProject\doSomeWork.py You would enter:

Program/Script: doSomeWork.py

Start in (optional): C:\pythonProject

Except that I specified my batch file as the program. So the important part is to specify the path to start your batch file in.

Devin
  • 21
  • 1