I have created a python program which uses selenium and chromedriver. I cannot successfully run this script (or any others using selenium) from the TaskScheduler in any way. However, it runs perfectly fine and does all tasks I need when I run it from Spyder. It also runs perfectly while logged in when I call it via the command line.
What does the program do when working as intended: Launches a chrome browser. Automates clicks and page requests. Downloads a file. -does stuff with files that is irrelevant to this post-
What does the program do when called from the TaskScheduler: Starts chrome but it does not appear (no visible browser, but task manager recognizes the chromedriver and chrome being kicked off and running persistently after the script is called) All of my clicks are on elements by full xpath so I thought maybe the invisible browser wouldn't break it, but it does indeed fail, never fetching the file download.
Possibly relevant information: My chromedriver is not on path, but is set via driver = webdriver.Chrome(r'F:\chromedriver.exe') and this works absolutely fine when run by Spyder or command line.
Task Scheduler input Action: Start a program Program/Script: C:\ProgramData\Anaconda3\python.exe Add arguments (optional): "C:\Users\[My_redacted_name]\.spyder-py3\[Client's_redacted_name]\[redacted_task].py"
What I know: The working directory as suggested in Python script not running in task scheduler does not fix anything.
Running from the command line C:\ProgramData\Anaconda3\python.exe C:\Users\[My_redacted_name]\.spyder-py3\[Client's_redacted_name]\[redacted_task].py yields the exact results as intended
No other programs I have made have had this kind of issue, and I have dozens of programs running via TaskScheduler with similar functionality to all the components OTHER than selenium / chromedriver.
I actually have two scripts using selenium that both encounter the same issue when running from command line. Their tasks are more or less the same, so solving ONE should solve the other, but it should be noted that the issue is not unique to a single script, but instead unique to scripts using selenium and running from task scheduler
I also see Selenium - Using Windows Task Scheduler vs. command line and am attempting to see if the single response with 0 votes could help, but I'm not sure if the issue is truly the same given it was for IE and on java.