web-dev-qa-db-ja.com

Python Selenium Exception AttributeError:Selenium.webdriver.ie.service.Serviceの「 'Service'オブジェクトには属性 'process' 'がありません」

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)

このエラーがテストスイートの実行を停止している理由を誰でも助けることができますか?これをどうやって解決しますか?

11
Riaz Ladhani

Seleniumをインストールし、コンソールのトレースバックログの最初の方で、スクリプトで「 'chromedriver'実行可能ファイルがPATHにある必要があります」などのエラーが発生したと仮定すると、次のことができるはずです。

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

これにより、chromedriverの場所をスクリプトに伝える必要があります。 Macでは通常/ usr/local/bin/chromedriverを使用できます。

14
CubeBot88

https://sites.google.com/a/chromium.org/chromedriver/downloads からクロムドライバーをダウンロードします

ファイルを解凍し、コードから次のように記述します。

     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 から取得

2
Tarek Hoteit