I have a python script which uses Selenium WebDriver to start a Chrome, open an URL, enter simple captcha, check if some data available (time for visit government organization) and repeat this process in 5 minutes.
I want it work in background. Headless
mode is not an option because site would show DDos Guard in that case.
I have tried to use driver.minimize_window()
but the windows activates for short periods for number input and click of button which is annoying when I work on PC.
Is it possible to make it work completely in background without activate Chrome window?

- 1,816
- 9
- 29
- 57
2 Answers
You can packaging your script using PyInstaller, then run it with Windows Task Scheduler (assuming you are using Windows)
- Install pyinstaller
pip install -U pyinstaller 2. Packaging your script (run in cmd) pyinstaller --onefile --name=your-package-name yourscript.py
Check pyinstaller docs and make sure add --hidden-import or --collect-data flag if needed.
- Setup your task scheduler:
Create basic task, choose task name, and description (if needed)
Set action to start a program then define your script name in Program/script
and make sure put your script folder path in Start in
Then voila. You can custom the trigger more detail in task properties (creating multiple triggers, specific conditions, etc...)
You could try to start your exe file as process manually using cmd/powershell like this SO answer, and some kind of process/service manager but I have never tried it yet.

- 672
- 1
- 17
When I use selenium and headless option don't work with me, I always do this trick by changing the window size and just leave it.
So, set the window size in the driver itself, like this:
driver.set_window_size(1, 1)
Or, set it as an argument, like this:
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('window-size=1,1')
Or use both.
I hope this helps you.

- 47
- 1
- 6