• 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

    • Rustdesk. https://rustdesk.com/ You can even set up your own relay server (if you desire).
    • ICYMI: 4TB Corsair MP700 PRO SE SSD is still selling at its lowest price by Fiza Ali Amazon US and Newegg are still offering the 4TB Corsair MP700 PRO SE solid-state drive at its new lowest price. The MP700 PRO SE is an M.2 2280 SSD that employs a PCIe 5.0 ×4 interface with NVMe 2.0, delivering sequential read speeds of up to 14,000MB/s and sequential write speeds of up to 12,000MB/s. It uses high-density 3D TLC NAND and carries a Total Bytes Written (TBW) rating of 3000. Furthermore, the drive can withstand vibration from 20Hz to 80Hz at 1.52mm and 80Hz to 2000Hz at 20G, as well as shocks up to 1500G. The drive incorporates AES 256-bit encryption and supports Microsoft DirectStorage, allowing compatible games to load assets directly to the GPU for reduced load times. Moreover, it operates within a temperature range of 0°C to +70°C, and can be stored between –40°C and +85°C at up to 93% relative humidity (40 °C). A heatsink is not included, so users must provide their own or rely on a motherboard’s integrated SSD cooling solution to maintain optimal thermals. Finally, the MP700 PRO SE is compatible with Windows 10, Windows 11, and macOS systems that provide an M.2 slot, and communicates via a standard M.2 2280 interface connector. 4TB Corsair MP700 PRO SE SSD: $549.99 (Amazon US) 12% off - $549.99 (Newegg) 9% off This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. You can also check out other SSD deals here. For hard disk drives, you can head over to our HDD deals section to see if anything from there matches your requirements. Make sure you also browse through Amazon US, Amazon UK, and Newegg US to find some other great tech deals. As an Amazon Associate, we earn from qualifying purchases.
    • "requiring individual licences from all rights-holders would impose an unmanageable administrative burden and could deter AI investment in the UK." Ah so plebs (humans) will forever be required to secure license, but AI should get a broad pass because it's too complicated. Not so "intelligent" after all? Plus, every opt out I have signed regarding Meta using my data was never presented to me in a clear way, I had to discover it here on neowin or some other news site with a link to do it. So what the government is saying is that they prefer to offer an opt out just to cover their asses, but good luck us plebs finding such a thing!
    • The look speaks volumes, doesn't it?  
  • Recent Achievements

    • First Post
      ClarkB earned a badge
      First Post
    • Week One Done
      Epaminombas earned a badge
      Week One Done
    • Week One Done
      Prestige Podiatry Care earned a badge
      Week One Done
    • Week One Done
      rollconults earned a badge
      Week One Done
    • Week One Done
      lilred1938 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      136
    2. 2
      Xenon
      129
    3. 3
      ATLien_0
      123
    4. 4
      +Edouard
      102
    5. 5
      snowy owl
      96
  • Tell a friend

    Love Neowin? Tell a friend!