Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
webdriver does not work
#1
Hello, I just started a new project and chromedriver does not work, I have the newest version of pycharm, Google chrome, and chromedriver.

The first problem was:

from selenium import webdriver
dirver = webdriver.Chrome("C:/chromedriver.exe")
I got this:
{error1}

Then I found this site:

https://exerror.com/deprecationwarning-e...he_Service

So I changed my code to:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service('C:/chromedriver.exe')
driver = webdriver.Chrome(service=s)
Errors:
{error2}

I have no idea what ca be wrong.
Larz60+ write Dec-06-2021, 05:11 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags on future posts.

Additionally, when posting errors, post in bbcode error tags instead of using images

Attached Files

Thumbnail(s)
       
Reply
#2
Use Code Tags
You most download version 96,97 is still in beta.
chromedriver.exe most be in Environment Variables Path if unsure place it in C:\Windows\chromedriver.exe
Here a example setup.
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")
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
url = "https://www.youtube.com/results?search_query=python"
browser.get(url)
# Example of using both to parse
time.sleep(2)
soup = BeautifulSoup(browser.page_source, 'lxml')
use_bs4 = title = soup.find('a', id="video-title")
print(use_bs4.text.strip())
print('-' * 25)
use_sel = browser.find_elements_by_css_selector('#video-title > yt-formatted-string')
print(use_sel[0].text) 
Output:
Learn Python - Full Course for Beginners [Tutorial] ------------------------- Learn Python - Full Course for Beginners [Tutorial]
Reply
#3
Thanks, now I used version 95 and it's working :)) and also sry for code tags and the rest of mistakes
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Fixture not returning webdriver element Nik1811 1 150 Apr-15-2024, 04:39 PM
Last Post: Nik1811
  Selenium Webdriver Python — ERR_NO_SUPPORTED_PROXIES TimofeyKolpakov 0 1,771 May-06-2023, 02:13 PM
Last Post: TimofeyKolpakov
  WebDriver' object has no attribute 'find_element_by_css_selector rickadams 3 5,892 Sep-19-2022, 06:11 PM
Last Post: Larz60+
  Multiple for loops selenium webdriver KRS 4 2,560 Mar-10-2020, 03:31 PM
Last Post: KRS

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020