Python Selenium Exception AttributeError: "'Service' object has no attribute 'process'" in selenium.webdriver.ie.service.Service
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37004635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Selenium Exception AttributeError: "'Service' object has no attribute 'process'" in selenium.webdriver.ie.service.Service
提问by Riaz Ladhani
I have a Selenium Python test suite. It starts to run but after a few mins the following error is thrown:
我有一个 Selenium Python 测试套件。它开始运行,但几分钟后抛出以下错误:
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?
任何人都可以帮助为什么这个错误阻止我的测试套件运行?我该如何解决这个问题?
回答by CubeBot88
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:
假设您已经安装了 selenium,并假设在控制台的回溯日志的早些时候,您的脚本中还有类似“'chromedriver' 可执行文件需要在 PATH 中”之类的信息,您应该能够执行以下操作:
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
这应该告诉您的脚本在哪里可以找到 chromedriver。在 Mac 上,您通常可以使用:/usr/local/bin/chromedriver
回答by Tarek Hoteit
Download chromium driver from https://sites.google.com/a/chromium.org/chromedriver/downloads
从https://sites.google.com/a/chromium.org/chromedriver/downloads下载 Chrome 驱动程序
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.
其中 /path/to/chromedriver 是 chromedriver 的位置。
This is the class declaration for Chrome Webdriver: selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', ...
这是 Chrome Webdriver 的类声明: selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', ...