Python Forum
Selenium webdriver error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Selenium webdriver error (/thread-24318.html)



Selenium webdriver error - WiPi - Feb-08-2020

Hi guys,
I'm very new to Python - trying to use Selenium to scrape dynamic web pages and can't even get over 1st hurdle!!!
from selenium import webdriver
browser = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')
browser.get("https://www.python.org/")
The browser opens but does not connect to the requested web page and I get the following error:

Output:
Traceback (most recent call last): File "C:\Users\Shane Duncan\OneDrive\Documents\Trading\MyFxBook Programs\Test code.py", line 32, in <module> browser = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe') File "C:\Users\Shane Duncan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "C:\Users\Shane Duncan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 98, in start self.assert_process_still_running() File "C:\Users\Shane Duncan\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 111, in assert_process_still_running % (self.path, return_code) selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files (x86)\Google\Chrome\Application\chrome.exe unexpectedly exited. Status code was: 0
I have no idea why I get this error - any help appreciated.


RE: Selenium webdriver error - metulburr - Feb-08-2020

you need to download chromedriver and link to that, not your local chrome exe


RE: Selenium webdriver error - WiPi - Feb-09-2020

I ran the chromedriver exe file and it opens the cmd window and just sits there ..open
I ran the python code again and same error as before.


RE: Selenium webdriver error - metulburr - Feb-09-2020

(Feb-09-2020, 11:07 AM)WiPi Wrote: I ran the chromedriver exe file and it opens the cmd window and just sits there ..open
You dont run that directly, you put it in your code's path. Or you can add the chromedriver's directory to Windows PATH variable to not have to put the path in your code.


RE: Selenium webdriver error - WiPi - Feb-09-2020

sorry yes I realised later doh!

Thank you this now works but I am sure I will have plenty more stupid questions as I get into the tough stuff!