0

I'm trying to implement the answer here to suppress the chromedriver.exe prompt:

https://stackoverflow.com/a/39937466/264975

which tells me to use the following:

from win32process import CREATE_NO_WINDOW

However, I cannot get win32process module to load. I am told that it requires pypiwin32, however, there is no information on how to use these modules? For instance, what am I actually supposed to import and from where?

I successfully installed pypiwin32 using pip however, I have no idea how to verify it is working due to the lack of help files.

Would be grateful for some pointers as to how to get the example working.

Does it matter that im on a 64 bit pc? I think the python I am using is 32 bit though.

Ke.
  • 2,484
  • 8
  • 40
  • 78

1 Answers1

0

Was trying to do the same thing.

Am on a Windows 10 64-bit machine using Python 2.7.

Kept on saying win32process not found.

I installed a bunch of different modules and a few command line install commands, but what got it working was after I installed this exe package pywin32-221.win-amd64-py2.7.exe from https://sourceforge.net/projects/pywin32/files/pywin32/

Then as https://stackoverflow.com/a/39937466/264975 instructs go to your Python folder, then

Lib\site-packages\selenium\webdriver\common\

and edit service.py (in the thread it mentions services.py but this is what was in my folder)

And include from win32process import CREATE_NO_WINDOW at the top of this script. Mine looks like this

import errno
import os
import platform
import subprocess
from subprocess import PIPE
from win32process import CREATE_NO_WINDOW
import time
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common import utils

then further down in this script look for def start(self):, and just add this to the end of self.process =

creationflags=CREATE_NO_WINDOW

So mine looks like this

        self.process = subprocess.Popen(cmd, env=self.env,
                                        close_fds=platform.system() != 'Windows',
                                        stdout=self.log_file,
                                        stderr=self.log_file,
                                        stdin=PIPE,
                                        creationflags=CREATE_NO_WINDOW)

That's all. Now the chromedriver.exe console does not pop-up at all in my python scripts.

That's what worked for me. Hard to say if it was a number of things together that made it work or just by installing the pywin32-amd64.exe package.

bbruman
  • 667
  • 4
  • 20
  • Also note that `CREATE_NO_WINDOW` just simply does not create the *window*/console ---, the driver still runs in the background. Make use of something like the `driver.quit()` command on the applicable lines in your script otherwise just an exit of the application/script will leave it in the background and pile up (especially in a dev environment :)) – bbruman Jun 16 '18 at 19:18