【问题标题】:Python Selenium Exception AttributeError: "'Service' object has no attribute 'process'" in selenium.webdriver.ie.service.ServicePython Selenium Exception AttributeError: "'Service' object has no attribute 'process'" in selenium.webdriver.ie.service.Service
【发布时间】:2016-08-28 12:40:46
【问题描述】:

我有一个 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

我的测试套件实现是:

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)

谁能帮忙解释为什么这个错误会阻止我的测试套件运行?我该如何解决?

【问题讨论】:

    标签: python python-2.7 selenium selenium-webdriver


    【解决方案1】:

    如果您已经安装了 selenium,并且假设在控制台的回溯日志中早些时候您的脚本中也有类似“'chromedriver' 可执行文件需要在 PATH 中”之类的内容,那么您应该能够做到:

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

    这应该告诉您的脚本在哪里可以找到 chromedriver。在 Mac 上,您通常可以使用:/usr/local/bin/chromedriver

    【讨论】:

      【解决方案2】:

      https://sites.google.com/a/chromium.org/chromedriver/downloads下载chromium驱动

      解压缩文件,然后从您的代码中编写如下内容:

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

      其中 /path/to/chromedriver 是您的 chromedriver 的位置。

      这是 Chrome Webdriver 的类声明:selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', ...

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

      【讨论】:

      • 是的,但仍然使用该代码,出现相同的错误:webdriver/chrome/webdriver.py", line 62, in __init__ self.service.start() Exception AttributeError: "'Service' object has no attribute 'process'" in &lt;bound method Service.__del__ of &lt;selenium.webdriver.chrome.service.Service object at 0x7f05180ff5d0&gt;&gt; ignored
      猜你喜欢
      • 2023-01-29
      • 1970-01-01
      • 1970-01-01
      • 2022-12-01
      • 2021-09-29
      • 2018-02-05
      • 1970-01-01
      • 2020-04-26
      • 2020-11-21
      相关资源
      最近更新 更多