I'm working on a python script to web-scrape and have gone down the path of using Chromedriver as one of the packages. I would like this to operate in the background without any pop-up windows. I'm using the option 'headless' on chromedriver and it seems to do the job in terms of not showing the browser window, however, I still see the .exe file running. See the screenshot of what I'm talking about. Screenshot
This is the code I am using to initiate ChromeDriver:
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["ignore-certificate-errors"])
options.add_argument('headless')
options.add_argument('window-size=0x0')
chrome_driver_path = "C:\Python27\Scripts\chromedriver.exe"
Things I've tried to do is alter the window size in the options to 0x0 but I'm not sure that did anything as the .exe file still popped up.
Any ideas of how I can do this?
I am using Python 2.7 FYI
import win32gui
andimport win32.lib.win32con as win32con
and in the code include something likeHwnd = win32gui.FindWindowEx(None,None,None,chrome_driver_path)
and thenwin32gui.ShowWindow(Hwnd,win32con.SW_HIDE)
later if you want to show it again, you need towin32gui.ShowWindow(Hwnd,win32con.SW_SHOW)
The code will completely hide the window. only viewable through programs such as task manager running in background – Anticlinal