Unable to hide Chromedriver console with CREATE_NO_WINDOW
Question:
- Python 3.11
- ChromeDriver 107.0.5304.62
- Chrome 107.0.5304.107
- Selenium 4.6.0
Chromedriver console always shows when I try to build exe with pyinstaller.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from subprocess import CREATE_NO_WINDOW
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = r'D:Testbinchrome.exe'
chrome_service = ChromeService(r'D:Testbinchromedriver.exe')
chrome_service.creationflags = CREATE_NO_WINDOW
driver = webdriver.Chrome(service=chrome_service, options=chrome_options)
driver.get('http://google.com')
I have tried to build exe with pyinstaller in different ways:
pyinstaller Test.py
pyinstaller Test.pyw
pyinstaller Test.py --windowed or --noconsole
pyinstaller Test.pyw --windowed or --noconsole
I also tried to change in venvLibsite-packagesseleniumwebdrivercommonservice.py at line 67
self.creation_flags = 0
to
self.creation_flags = 1
I also tried different chrome/chromedriver combinations
Answers:
It doesn’t work with selenium 4.6.0 version. It work with selenium 4.5.0
It appears that somewhere along the line (not sure which release), "creationflags" changed to "creation_flags".
Try changing your code from:
chrome_service.creationflags = CREATE_NO_WINDOW
to
chrome_service.creation_flags = CREATE_NO_WINDOW
and see if that works.
Try to figure out what happend, I just found this commit change Service varaible from creationflags
to creation_flags
.
For the people who want to hide the console window for ChromDriver. You have to use selenium
with version above 4.0.0.
If before 4.5.0:
chrome_service.creationflags = CREATE_NO_WINDOW
Or after 4.6.0
chrome_service.creation_flags = CREATE_NO_WINDOW
- Python 3.11
- ChromeDriver 107.0.5304.62
- Chrome 107.0.5304.107
- Selenium 4.6.0
Chromedriver console always shows when I try to build exe with pyinstaller.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from subprocess import CREATE_NO_WINDOW
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = r'D:Testbinchrome.exe'
chrome_service = ChromeService(r'D:Testbinchromedriver.exe')
chrome_service.creationflags = CREATE_NO_WINDOW
driver = webdriver.Chrome(service=chrome_service, options=chrome_options)
driver.get('http://google.com')
I have tried to build exe with pyinstaller in different ways:
pyinstaller Test.py
pyinstaller Test.pyw
pyinstaller Test.py --windowed or --noconsole
pyinstaller Test.pyw --windowed or --noconsole
I also tried to change in venvLibsite-packagesseleniumwebdrivercommonservice.py at line 67
self.creation_flags = 0
to
self.creation_flags = 1
I also tried different chrome/chromedriver combinations
It doesn’t work with selenium 4.6.0 version. It work with selenium 4.5.0
It appears that somewhere along the line (not sure which release), "creationflags" changed to "creation_flags".
Try changing your code from:
chrome_service.creationflags = CREATE_NO_WINDOW
to
chrome_service.creation_flags = CREATE_NO_WINDOW
and see if that works.
Try to figure out what happend, I just found this commit change Service varaible from creationflags
to creation_flags
.
For the people who want to hide the console window for ChromDriver. You have to use selenium
with version above 4.0.0.
If before 4.5.0:
chrome_service.creationflags = CREATE_NO_WINDOW
Or after 4.6.0
chrome_service.creation_flags = CREATE_NO_WINDOW