Selenium-manager.exe console window briefly popping up
When you build the script below into an executable using Pyinstaller by running pyinstaller --windowed my_script.py a console window named selenium-manager.exe briefly pops up. This only occurs if you run the executable and not the script as a python file, I'm assuming this cause there's already a console window so windows doesn't create a new one.
I've narrowed it down to the following method selenium.webdriver.common.selenium_manager.SeleniumManager.run. I believe this is caused by the call to subprocess.run which on windows if made without the flagcreationflags=subprocess.CREATE_NO_WINDOW a console window is created if one is unavailable.
Possible fix:
if sys.platform == "win32":
completed_proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags=subprocess.CREATE_NO_WINDOW)
else:
completed_proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
For the code below run: pyinstaller --windowed my_script.py
from subprocess import CREATE_NO_WINDOW
from selenium.webdriver.chrome.service import Service
from selenium.webdriver import Chrome, ChromeOptions
def setup_options(options: ChromeOptions) -> ChromeOptions :
options.add_argument('--headless=new')
options.add_argument('--disable-extensions')
options.add_argument('--disable-infobars')
options.add_argument('--no-sandbox')
return options
def setup_driver() -> Chrome:
service_chrome = Service()
service_chrome.creation_flags = CREATE_NO_WINDOW
options = setup_options(ChromeOptions())
return Chrome(service=service_chrome, options=options)
driver = setup_driver()
# Do some automation
driver.quit()
Relevant log output
Operating System
Windows-10-10.0.19045-SP0
Selenium version
Python 4.10.0
What are the browser(s) and version(s) where you see this issue?
Chrome 115.0.5790.110
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver, MsedgeDriver
Are you using Selenium Grid?
No
Selenium-manager.exe console window briefly popping up
When you build the script below into an executable using Pyinstaller by running
pyinstaller --windowed my_script.pya console window named selenium-manager.exe briefly pops up. This only occurs if you run the executable and not the script as a python file, I'm assuming this cause there's already a console window so windows doesn't create a new one.I've narrowed it down to the following method
selenium.webdriver.common.selenium_manager.SeleniumManager.run. I believe this is caused by the call tosubprocess.runwhich on windows if made without the flagcreationflags=subprocess.CREATE_NO_WINDOWa console window is created if one is unavailable.Possible fix:
For the code below run: pyinstaller --windowed my_script.py
Relevant log output
Operating System
Windows-10-10.0.19045-SP0
Selenium version
Python 4.10.0
What are the browser(s) and version(s) where you see this issue?
Chrome 115.0.5790.110
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver, MsedgeDriver
Are you using Selenium Grid?
No