Python script with Selenium browser flow.
Windows Server 2016 Standard Python 3.8.1 Firefox 86.0
Executing the python script (always non-healess i.e. with option headless DISABLED) from Windows in 3 different ways:
a) manually from cmd window prompt "python scriptname.py" b) from Task Scheduler with option "Run only when user is logged on" c) from Task Scheduler with option "Run whether user is logged on or not"
Always logged in as Administrator and Task Schedule entry for the script setup as "When running the task use the following account: Administrator". User Administrator has Desktop Enabled.
Need to take screenshots at different steps of the python script above for two scenarios:
- show what is seen in the browser context (using browser.save_screenshot works fine)
- show a complete screen dump that includes the whole screen including the browser.
The challenge is in step 2) above.
To create pics with complete screen dump of the whole screen I have tried: pyautogui.screenshot() PIL wx Pillow mss
All of the above work fine when running the script by hand or from Task Scheduler in mode "Run only when user is logged on"
They fail when running from Task Scheduler in mode "Run whether user is logged on or not"
The only screen dump option that has worked in all modes, manually, TS in mode "Run only when user is logged on" and TS in mode "Run whether user is logged on or not" is:
image = pyscreenshot.grab() image.save("GeeksforGeeks.png")
It produces a fine screendump when Task Scheduler is in mode "Run only when user is logged on" HOWEVER when executing from Task Scheduler in mode "Run whether user is logged on or not" IT PRODUCES A TOTALLY BLACK PIC.
Summary:
I) Running script by hand a pic of the browser context and a pic of the complete screen is correctly created and saved to disk.
II) Running from Task Scheduler "Run only when user is logged on" a pic of the browser context and a pic of the complete screen is correctly created and saved to disk.
III) Running from Task Scheduler "Run whether user is logged on or not" a pic of browser context is correctly created and saved to disk. However all apps (pyautogui.screenshot(), PIL, wx, Pillow, mss) give an error
Someone have an idea of what is the problem?