• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

Issues With Selenium: Adding Path To Chrome-Webdriver

Question

tarifa    2

 

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_US")
time.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('title')
print(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.


 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.