2

I was learning selenium for python automation, but I am stuck with following error. Can anyone please help me?

This is my code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
website = 'https://www.adamchoi.co.uk/overs/detailed'
path = r"C:\Users\User\Downloads\Compressed\chromedriver"
driver = webdriver.Chrome(service=Service(path))
driver.get(website)
driver.quit()

Error log,

Traceback (most recent call last): File "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py", line 5, in driver = webdriver.Chrome(service=Service(path)) File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in init super().init( File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chromium\webdriver.py", line 103, in init self.service.start() File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 106, in start PS C:\Windows\System32\WindowsPowerShell\v1.0> & "C:/Program Files/Python38/python.exe" "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py" Traceback (most recent call last): File "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py", line 5, in driver = webdriver.Chrome(service=Service(path)) File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in init super().init( File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chromium\webdriver.py", line 103, in init self.service.start() File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 106, in start
self.assert_process_still_running() File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 117, in assert_process_still_running return_code = self.process.poll() AttributeError: 'Service' object has no attribute 'process'

2 Answers 2

4

I see you are working on Windows OS computer.
If so, path should include exe executable file extension.
In your case:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
website = 'https://www.adamchoi.co.uk/overs/detailed'
path = "C:\Users\User\Downloads\Compressed\chromedriver.exe"
driver = webdriver.Chrome(service=Service(path))
driver.get(website)

My working code is:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)

Where C:\webdrivers\chromedriver.exe is the actual location of chromedriver.exe

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer, I have another question if you reply it will help me, my code is(only main part), web = 'audible.com/search' container = driver.find_element(By.CLASS_NAME,'adbl-impression-container') products = container.find_elements(By.XPATH,'//li') for product in products[:5]: book_title.append(product.find_element(By.XPATH, '//h3[contains(@class,"bc-heading")]').text) but,every time I got an empty list,can you please see this
0

in my case (Windows OS) this works:

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service

    path =r"C:\path\chromedriver_win32\chromedriver.exe"
    service = Service(executable_path=path)
    driver = webdriver.Chrome(service=service)
    web = 'https://en.wikipedia.org/wiki/1982_FIFA_World_Cup'
    driver.get(web)

Cheers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.