Stats: 3,229,005 members, 8,080,726 topics. Date: Tuesday, 18 February 2025 at 12:09 AM |
Nairaland Forum / Science/Technology / Programming / Python Selenium Webdriver Error (2332 Views)
What Is Selenium Webdriver? / Selenium Automation Testing / How To Wait For Page To Load/ready In Selenium Webdriver (2) (3) (4)
Python Selenium Webdriver Error by MakindeHassan: 10:02pm On Jun 25, 2020 |
Hello Pyhton Guru's, Please I have an issue I need help on. I am trying to scrape a dynamic website using selenium as the normal requests module does not do the trick. I have pip installed selenium and imported but however for some reason I always get an error message related to the WebDriver linking with selenium. Both webdriver.firefox() and webdriver.Chrome() doesn't seem to work. This is the code; import selenium import time from selenium import webdriver driver = webdriver.Chrome() driver.get('https://web.whatsapp.com/') this is the error message; Message: 'chromedriver.exe' executable needs to be in PATH. import selenium import time from selenium import webdriver driver = webdriver.Chrome(executable_path=r"C:\Users\User\PycharmProjects\play\ven\chromedriver.exe" ) driver.get('https://web.whatsapp.com/') Even when I declare the path the WebDriver is installed I still get same error. Need help even on team viewer I wouldn't mind |
Re: Python Selenium Webdriver Error by Shepherdd(m): 10:25pm On Jun 25, 2020 |
You have to download a driver for the browser but let me give you a shortcut. Do pip install webdriver-manager Then in your Python file add from webdriver_manager.chrome import ChromeDriverManager This will fetch the latest driver binary for you. |
Re: Python Selenium Webdriver Error by MakindeHassan: 10:31pm On Jun 25, 2020 |
Thanks. just tried this and this was the error message; [WDM] - Current google-chrome version is 83.0.4103 [WDM] - Get LATEST driver version for 83.0.4103 [WDM] - There is no [win32] chromedriver for browser 83.0.4103 in cache [WDM] - Get LATEST driver version for 83.0.4103 [WDM] - Trying to download new driver from http://chromedriver.storage.googleapis.com/83.0.4103.39/chromedriver_win32.zip [WDM] - Driver has been saved in cache [C:\Users\User\.wdm\drivers\chromedriver\win32\83.0.4103.39] Traceback (most recent call last): File "C:/Users/User/PycharmProjects/nairaplay/venv/scrape3.py", line 7, in <module> driver = webdriver.Chrome(ChromeDriverManager().install()) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__ RemoteWebDriver.__init__( File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process. Shepherdd: |
Re: Python Selenium Webdriver Error by Shepherdd(m): 10:36pm On Jun 25, 2020 |
MakindeHassan: Did you restart pycharm after the install. If no please restart it. |
Re: Python Selenium Webdriver Error by MakindeHassan: 10:50pm On Jun 25, 2020 |
Shepherdd: I just restarted pycharm and tried again, I also downloaded chromedriver_win32.zip and extracted it to C:\Users\User\.wdm\drivers\chromedriver\win32\83.0.4103.39 this is the error; [WDM] - Current google-chrome version is 83.0.4103 [WDM] - Get LATEST driver version for 83.0.4103 [WDM] - Driver [C:\Users\User\.wdm\drivers\chromedriver\win32\83.0.4103.39\chromedriver.exe] found in cache Traceback (most recent call last): File "C:/Users/User/PycharmProjects/nairaplay/venv/scrape3.py", line 7, in <module> driver = webdriver.Chrome(ChromeDriverManager().install()) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__ RemoteWebDriver.__init__( File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\User\PycharmProjects\nairaplay\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process. |
Re: Python Selenium Webdriver Error by Shepherdd(m): 10:58pm On Jun 25, 2020 |
Ok go to this https://chromedriver.storage.googleapis.com/index.html?path=83.0.4103.39/ and download the one for Win32 then unzip the file to your working directory. Now add the path to driver=webdriver.Chrome(executable_path="" ) Then add the directory to your path inside environment variables. |
Re: Python Selenium Webdriver Error by MakindeHassan: 11:24pm On Jun 25, 2020 |
Shepherdd: thank you for being helpful and im sorry im a novice at this but this is the new code after downloading with the link you sent and extracting to path import selenium import time from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(executable_path=r'C:\Users\User\.wdm\drivers\chromedriver\win32\chromedriver.exe') driver.get('https://web.whatsapp.com/') This is the error message; selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process. |
Re: Python Selenium Webdriver Error by Shepherdd(m): 12:27am On Jun 26, 2020 |
MakindeHassan: Ok try from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') driver = webdriver.Chrome('path to driver',chrome_options=chrome_options) |
Re: Python Selenium Webdriver Error by Shepherdd(m): 12:29am On Jun 26, 2020 |
MakindeHassan: Or from selenium.webdriver.chrome.options import Options options = Options() options.binary_location = "C:\\path\\to\\chrome.exe" options.add_argument("--start-maximized" ) options.add_argument("--no-sandbox" ) options.add_argument("--disable-dev-shm-usage" ) options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) driver = webdriver.Chrome(options=options, executable_path=r'C:\path\to\chromedriver.exe') |
Re: Python Selenium Webdriver Error by MakindeHassan: 10:18am On Jun 26, 2020 |
Shepherdd: Ran the second code and got (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Users\User\PycharmProjects\nairaplay\venv\selenium\webdriver\chrome\chromedriver.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.) |
Re: Python Selenium Webdriver Error by Shepherdd(m): 10:24am On Jun 26, 2020 |
MakindeHassan: Why not update chrome and see if the issue persists. You will also need to download the latest chrome driver too. |
Re: Python Selenium Webdriver Error by javaRookie: 8:31am On Jun 28, 2020 |
Update your chrome and download a compatible chrome driver for it. Place this chrome driver on the folder you installed Python. It should work. |
Re: Python Selenium Webdriver Error by MakindeHassan: 10:19am On Jul 03, 2020 |
javaRookie: Thank you for your support and time, I really appreciate. I downloaded the professional version of Pycharm and it worked out so I suspect the free version of Pycharm is limited to certain functions. |
Re: Python Selenium Webdriver Error by myles16(m): 3:21am On Jul 04, 2020 |
That's why I've multiple editors and IDE, I noticed selenium doesn't work on my pycharm too but it works on VScode. Try downloading wing IDE, VScode, jupyter notebook and pycharm...cause some codes run on some IDEs and editors and won't run on some, and next time just create a variable named PATH and copy the Chromedriver or Firefox driver path, paste and quote it, then you call your path so as to get the site you want to scrape or visit |
(1) (Reply)
Developing Desktop Application Using Actionscript / Lets Learn React Native,javascript,react Js And Node Js Together(alimosho LGA) / What Are The Best Offshore Software Development Companies To Develop Customized
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 35 |