To hide the webdriver console window, I had to edit the Libsite-packagesseleniumwebdrivercommonservices.py in my case but I was using PhantomJS. PhantomJS imports and uses this file to start its process. Basically, I added the following creation flag to the Start method:
def start(self):
"""
Starts the Service.
:Exceptions:
- WebDriverException : Raised either when it can't start the service
or when it can't connect to the service
"""
try:
cmd = [self.path]
cmd.extend(self.command_line_args())
self.process = subprocess.Popen(cmd, env=self.env,
close_fds=platform.system() != 'Windows',
stdout=self.log_file, stderr=self.log_file, creationflags=CREATE_NO_WINDOW)
except TypeError:
raise` in bold.
Also add to the imports this line from win32process import CREATE_NO_WINDOW
This should also work for the Chrome webdriver, as its service.py also imports this very same file, though I have not had time to try.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…