Skip to content

Commit d78a8ec

Browse files
JefferyVinJefferyVin
and
JefferyVin
authored
[py] disable console appearing on windows when running in pythonw (#12715)
Co-authored-by: JefferyVin <jefferyfan@Hifo>
1 parent ed7ca49 commit d78a8ec

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

py/selenium/webdriver/common/service.py

+26-10
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,32 @@ def _start_process(self, path: str) -> None:
202202
cmd.extend(self.command_line_args())
203203
close_file_descriptors = self.popen_kw.pop("close_fds", system() != "Windows")
204204
try:
205-
self.process = subprocess.Popen(
206-
cmd,
207-
env=self.env,
208-
close_fds=close_file_descriptors,
209-
stdout=self.log_output,
210-
stderr=self.log_output,
211-
stdin=PIPE,
212-
creationflags=self.creation_flags,
213-
**self.popen_kw,
214-
)
205+
if system() == "Windows":
206+
si = subprocess.STARTUPINFO()
207+
si.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
208+
si.wShowWindow = subprocess.SW_HIDE
209+
self.process = subprocess.Popen(
210+
cmd,
211+
env=self.env,
212+
close_fds=close_file_descriptors,
213+
stdout=self.log_output,
214+
stderr=self.log_output,
215+
stdin=PIPE,
216+
creationflags=self.creation_flags,
217+
startupinfo=si,
218+
**self.popen_kw,
219+
)
220+
else:
221+
self.process = subprocess.Popen(
222+
cmd,
223+
env=self.env,
224+
close_fds=close_file_descriptors,
225+
stdout=self.log_output,
226+
stderr=self.log_output,
227+
stdin=PIPE,
228+
creationflags=self.creation_flags,
229+
**self.popen_kw,
230+
)
215231
logger.debug(f"Started executable: `{self._path}` in a child process with pid: {self.process.pid}")
216232
except TypeError:
217233
raise

0 commit comments

Comments
 (0)