Error from selenium : AttributeError: 'Service' object has no attribute 'process'
Question:
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:UsersUserDownloadsCompressedchromedriver"
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:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromewebdriver.py", line 81,
in init
super().init(
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromiumwebdriver.py", line 103, in init
self.service.start()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 106, in start
PS C:WindowsSystem32WindowsPowerShellv1.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:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromewebdriver.py", line 81, in init
super().init(
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromiumwebdriver.py", line 103, in init
self.service.start()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 106, in start
self.assert_process_still_running()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 117, in assert_process_still_running
return_code = self.process.poll()
AttributeError: ‘Service’ object has no attribute ‘process’
Answers:
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:UsersUserDownloadsCompressedchromedriver.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:webdriverschromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
Where C:webdriverschromedriver.exe
is the actual location of chromedriver.exe
in my case (Windows OS) this works:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
path =r"C:pathchromedriver_win32chromedriver.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.
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:UsersUserDownloadsCompressedchromedriver"
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:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromewebdriver.py", line 81,
in init
super().init(
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromiumwebdriver.py", line 103, in init
self.service.start()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 106, in start
PS C:WindowsSystem32WindowsPowerShellv1.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:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromewebdriver.py", line 81, in init
super().init(
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdriverchromiumwebdriver.py", line 103, in init
self.service.start()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 106, in start
self.assert_process_still_running()
File "C:UsersUserAppDataRoamingPythonPython38site-packagesseleniumwebdrivercommonservice.py", line 117, in assert_process_still_running
return_code = self.process.poll()
AttributeError: ‘Service’ object has no attribute ‘process’
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:UsersUserDownloadsCompressedchromedriver.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:webdriverschromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
Where C:webdriverschromedriver.exe
is the actual location of chromedriver.exe
in my case (Windows OS) this works:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
path =r"C:pathchromedriver_win32chromedriver.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.