Python Selenium Exception AttributeError: "'Service' object has no attribute 'process'" in selenium.webdriver.ie.service.Service
Asked Answered
A

4

18

I have a Selenium Python test suite. It starts to run but after a few mins the following error is thrown:

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.ie.service.Service object at 0x0000000002610DD8>> ignored

My test suite implementation is:

import unittest
from HTMLTestRunner2 import HTMLTestRunner
import os
import Regression_TestCase.RegressionProject_TestCase2


# get the directory path to output report file
#result_dir = os.getcwd()
result_dir = r"E:\test_runners\selenium_regression_test_5_1_1\ClearCore - Regression Test\TestReport"

# get all tests from SearchProductTest and HomePageTest class
search_tests = unittest.TestLoader().loadTestsFromTestCase(Regression_TestCase.RegressionProject_TestCase2.RegressionProject_TestCase2)

# create a test suite combining search_test
re_tests = unittest.TestSuite([search_tests])

# open the report file
outfile = open(result_dir + "\TestReport.html", "w")

# configure HTMLTestRunner options
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile,
                                       title='Test Report',
                                       description='Smoke Tests')

# run the suite using HTMLTestRunner
runner.run(re_tests)

Can anyone help why this error is stopping my test suite from running? How do I solve this?

Aborticide answered 3/5, 2016 at 12:48 Comment(1)
My issue was due to chromedriver file not having execution permission. Running chmod +x path_to/bin/chromedriver fixes the issue.Nessi
G
22

Provided you have installed selenium, and assuming that earlier in the console's traceback log you also got something like "'chromedriver' executable needs to be in PATH" in your script, you should be able to do:

from selenium import webdriver
driver = webdriver.Chrome("/path/to/chromedriver")

This should tell your script where to find chromedriver. On a Mac you can usually use: /usr/local/bin/chromedriver

Gaylord answered 7/6, 2016 at 10:58 Comment(0)
R
3

Download chromium driver from https://sites.google.com/a/chromium.org/chromedriver/downloads

Unzip the file and then from your code, write something like:

     from selenium import webdriver 
     driver = webdriver.Chrome("/path/to/chromedriver")

where /path/to/chromedriver is the location of your chromedriver.

This is the class declaration for Chrome Webdriver: selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', ...

taken from https://seleniumhq.github.io/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html#module-selenium.webdriver.chrome.webdriver

Ritter answered 21/11, 2016 at 21:25 Comment(4)
Yes, but still with that code, there is the same error: webdriver/chrome/webdriver.py", line 62, in __init__ self.service.start() Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x7f05180ff5d0>> ignored Alcibiades
im trying to convert a webscrapper from windows to linux and getting the same problemWooten
Did u find the solution. I too facing the same Issue.Ri
If you are using Windows, you should put the chromedriver.exe on C:\Windows. Then the code should go something as follow: service = Service("C:\Windows\chromedriver.exe") driver = webdriver.Chrome(service=service)Fisherman
Q
2

This page comes up first on Google, but only suggests that you are declaring you path incorrectly.

If you are reading this, try making sure the chromedriver is an executable:

run this command in the path of the driver:

sudo chmod a+x chromedriver
Quittance answered 3/2, 2023 at 7:18 Comment(0)
R
0

Given what @CubeBot88 had already written, another way to get the chromedriver executable in PATH is to do as follow:

from os
from selenium import webdriver 
os.environ['PATH'] += "/path/to/chromedriver"
driver = webdriver.Chrome()

The above way puts the path to chromedriver to environment variable PATH only in this program, allowing independent PATH in different situations.

Rattly answered 22/1, 2023 at 16:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.