splinter icon indicating copy to clipboard operation
splinter copied to clipboard

chromedriver doesn't work on Windows

Open ericrommel opened this issue 7 years ago • 3 comments

Dears,

I know that the Splinter doesn't have support for Windows, but you mention that it should be work fine if the webdriver is in the path. I read #173 and #119, but they didn't help me. I put the chromedriver.exe in the path, as you can see here:

def before_all(context):
    if os.name == 'nt':
        sys.path.append("C:\\webdrivers\\chrome\\chromedriver.exe")
        driver = webdriver.Chrome("C:\\webdrivers\\chrome\\chromedriver.exe")
    print(sys.path)
    context.browser = Browser('chrome', headless=st.VISIBLE)

CONSOLE:
[... 'C:\\webdrivers\\chrome\\chromedriver.exe'...]
DevTools listening on ws://127.0.0.1:52126/devtools/browser/8a686683-c40d-4c6c-a1d5-2783f0b03378
HOOK-ERROR in before_all: WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
HOOK-ERROR in after_all: AttributeError: 'Context' object has no attribute 'browser'

Could you help with this?

ericrommel avatar Jun 19 '19 22:06 ericrommel

sys.path isn't going to change the OS path, just the path for finding modules.

https://docs.python.org/3/library/sys.html#sys.path

javascript-error avatar Jun 20 '19 15:06 javascript-error

You're also instantiating both selenium and splinter separately.

If you want to pass a custom path to the webdriver through Splinter, off the top of my head you should use:

browser = Browser('chrome', executable_path='...')

javascript-error avatar Jun 20 '19 15:06 javascript-error

Yes, you are right. Unfortunately, only add the .exe at Environment Variables didn't work. That's why I was trying to use sys.path. Using executable_path works fine. Thank you so much for your help.

ericrommel avatar Jun 20 '19 18:06 ericrommel