• 0

Issues With Selenium: Adding Path To Chrome-Webdriver


Question

 

hello and good day dear all 

 

 


due to some tests with a selenium-based-parser i wanted to install the package on my machine. on a win 10 system see what has happened. --- see below the script... 

 

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import time
 
#--| Setup
options = Options()
#options.add_argument("--headless")
#options.add_argument("--window-size=1980,1020")
#options.add_argument('--disable-gpu')
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get("https://login.wordpress.org/?locale=en_UStitime.sleep(2)
user_name = browser.find_element_by_css_selector('#user_login')
user_name.send_keys("Test_user")
password = browser.find_element_by_css_selector('#user_pass')
password.send_keys("123456")
time.sleep(5)
submit = browser.find_elements_by_css_selector('#wp-submit')[0]
submit.click()
 
# Example send page source to BeautifulSoup or selenium for parse
soup = BeautifulSoup(browser.page_source, 'lxml')
use_bs4 = soup.find('titlerint(use_bs4.text)
#print('*' * 25)
#use_sel = browser.find_elements_by_css_selector('div > div._1vC4OE')
#print(use_sel[0].text)


after having had a closer look at the preliminaries i - note: i had to install wheel first i finally got there to test the script- 
see the full story:_ finally i installed wheel - so i got back the following: 

Windows PowerShell

PS C:\WINDOWS\system32> pip install -U selenium
Requirement already up-to-date: selenium in c:\program files\python37\lib\site-packages (3.141.0)
Requirement already satisfied, skipping upgrade: urllib3 in c:\program files\python37\lib\site-packages (from selenium) (1.25.8)
Could not build wheels for selenium, since package 'wheel' is not installed.
Could not build wheels for urllib3, since package 'wheel' is not installed.
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\program files\python37\python.exe -m pip install --upgrade pip' command.
PS C:\WINDOWS\system32> pip install wheel
Collecting wheel
  Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: wheel
Successfully installed wheel-0.34.2
WARNING: You are using pip version 20.1; however, version 20.1.1 is available.
You should consider upgrading via the 'c:\program files\python37\python.exe -m pip install --upgrade pip' command.
PS C:\WINDOWS\system32>

now i will testrun the selenium code from above... and i did it: now i get back the following: 


traceback (most recent call last):
File "C:\Users\Kasper\AppData\Local\Temp\atom_script_tempfiles\23970790-b56b-11ea-bc7c-ab8702b78510", line 12, in <module>
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Program Files\Python37\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
[Finished in 0.746s]

 

i guess that i now have to set the paths of the chromedriver in the code.


 

1 answer to this question

Recommended Posts

  • 0

You can test if it actually is in the Python PATH, if you open a cmd and type in chromedriver and hit Enter. If Starting ChromeDriver 2.15.322448 is appearing, the PATH is set appropriately and there is something else going wrong. Then try the following:

Download ChromeDriver 

Then you have multiple options:

  • Add it to your system path
  • Put it in the same directory as your python script
  • Specify the location directly via executable_path
driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Plenty of info (benchmarks etc) out there about how turning off e-cores can increase performance in certain workloads. Which tells me that Microsoft or Intel can’t get this mess of cores sorted out. At work we have this lab and someone was testing (TrueNas performance testing) ESXi on a white box setup that had a 13700K in it and ESXi would purple screen every time until they turned off ecores.
    • I've been using OneDrive for photos and documents since Windows 8.1 came out and it's been the best way to keep a backup of what I have. I also use GoogleDrive on my phone with Android 15 to back up my phone. Over the past 12 years, I've seen people losing data on their PC or phone because they don't use cloud services. Even though I warn them to use them. Especially those who make money working on their PC with thousands of files. A 1TB cloud service is extremely cheap these days and there's no reason for you not to use one. I've seen people losing valuable data on their phone because they don't use GoogleDrive on their phone and this is much more common than on a PC. On Windows, I've seen people having hardware problems with their HD and SSD and losing all their data just because they refused to use OneDrive, which offered the backup option. There's still an external SSD as a second copy to be used together with your OneDrive. Bitlocker is completely safe, you will only have problems with it if you use bad programs that mess with the integrity of Windows. Your iPhone and Android also have encryption and if you mess with the system gears it can bug and you can lose your data too. Windows 11 is perfect if used correctly. But people are stupid enough to buy a brand new car, open the engine and start messing with it until it stops working, and then go to the car manufacturer to complain that it stopped working just because the user messed up the engine.
    • Hey it's not my fault a politician's team made a tech blunder; a significant one at that, is it?
  • Recent Achievements

    • One Month Later
      mevinyavin earned a badge
      One Month Later
    • Week One Done
      rozermack875 earned a badge
      Week One Done
    • Week One Done
      oneworldtechnologies earned a badge
      Week One Done
    • Veteran
      matthiew went up a rank
      Veteran
    • Enthusiast
      Motoman26 went up a rank
      Enthusiast
  • Popular Contributors

    1. 1
      +primortal
      684
    2. 2
      ATLien_0
      266
    3. 3
      Michael Scrip
      196
    4. 4
      +FloatingFatMan
      181
    5. 5
      Steven P.
      140
  • Tell a friend

    Love Neowin? Tell a friend!