Python: clean-up error in Chrome / IE "Service" in selenium 2.49 #1504
Closed
Description
In Selenium 2.49 the Service objects were refactored to use a common base class. This common base class now contains a "del" method (which is not a bad thing in itself). However if the driver was quit before this "del" fails.
Try to execute the following Python script:
import os
from selenium import webdriver
from time import sleep
def spam():
webDriver = webdriver.Chrome(chrome_options=None)
webDriver.get("http://www.google.com")
sleep(1)
webDriver.quit()
os.environ['no_proxy'] = '127.0.0.1,localhost'
spam()
sleep(1)
This results in Python 2.7:
Exception urllib2.URLError: URLError(error(10061, 'No connection could be made because the target machine actively refused it'),) in <bound method Service.__del
__ of <selenium.webdriver.chrome.service.Service object at 0x0000000002583080>> ignored
With selenium 2.49 this returns an URLError in the "send_remote_shutdown_command". With 2.48 this works fine.
What is happening (if I am not completely mistaken) is that webDriver.quit() already called the "stop" method in the Service class. After the "spam" method is finished garbage collection comes into effect and the "del" method is called which calls this method again. Of course the port is already closed and the request fails.
Metadata
Assignees
Labels
No labels