我有以下設置:WebDriverException:消息:退出
Linux
Python 2.7.6
Mozilla Firefox 52.2.0
geckodriver 0.18.0
selenium Version: 3.4.3
我運行一個簡單的Python腳本:
import time
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/tmp')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'image/png')
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("file:////home/temp-plot.html")
export_button = driver.find_element_by_xpath("//a[@data-title='Download plot as a png']")
export_button.click()
time.sleep(10)
driver.quit()
但是,當我到達driver.quit()
,我有以下的錯誤:
Traceback (most recent call last):
File "conversor.py", line 17, in <module>
driver.quit()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 181, in quit
RemoteWebDriver.quit(self)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 551, in quit
self.execute(Command.QUIT)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: quit
如果我運行driver.close()
代替driver.quit()
,我都無辰恐怖消息,但另一方面,我發現geckodriver進程沒有被殺死,這對我來說是一個問題。
root 14572 1 0 11:56 pts/0 00:00:00 geckodriver --port 39203
我該如何解決這個異常錯誤?或者你建議我做什麼?
感謝
如何調用'webdriver.quit()'在'webdriver.close()' –
@GaurangShah之後會出現相同的行爲:我有異常並且進程沒有被終止。 – davidlimpo