Reputation: 149
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:\Test\bin\chrome.exe'
chrome_service = ChromeService(r'D:\Test\bin\chromedriver.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 venv\Lib\site-packages\selenium\webdriver\common\service.py at line 67
self.creation_flags = 0
to
self.creation_flags = 1
I also tried different chrome/chromedriver combinations
Upvotes: 2
Views: 2287
Reputation: 21
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
Upvotes: 2
Reputation: 113
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.
Upvotes: 4
Reputation: 149
It doesn't work with selenium 4.6.0 version. It work with selenium 4.5.0
Upvotes: 1