12

Newbee here. Kindly explain why this issue happened and how to fix it.

Error:

"C:\Program Files (x86)\Python36-32\python.exe" C:/Users/Vivek-Pc/PycharmProjects/tryOutSeries/searchTryout2.py Exception ignored in: > Traceback (most recent call last): File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 173, in del File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 149, in stop File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 120, in send_remote_shutdown_command ImportError: sys.meta_path is None, Python is likely shutting down Process finished with exit code 0

Code Used:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver_path = "c:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\chrome\chromedriver"
b_obj = webdriver.Chrome(driver_path)
b_obj.implicitly_wait(15)
b_obj.maximize_window()
b_obj.get('http://stackoverflow.com/')

search_box = b_obj.find_element_by_name('q')
search_box.clear()
search_box.send_keys("Selenium")
search_box.submit()
b_obj.close()

Environment Info:

Windows, Selenium, Python, Chrome (chromedriver.exe) & PyCharm

Patryk
  • 22,602
  • 44
  • 128
  • 244
Vivek22
  • 836
  • 1
  • 12
  • 19

3 Answers3

13

I've reproduced the same error using Python 3.6, Selenium 3.0.2 and ChromeDriver 2.27 (everything latest at this point).

The problem appears to happen when the Python selenium webdriver tries to stop the chromedriver service either when you explicitly close the driver, or when the script execution simply ends (and the __del__ method gets to be executed).

Reported the issue to Python/Selenium github issue tracker:

Workaround:

I found that using driver.quit() instead of driver.close() helps to workaround the problem.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Just to let you know. Even without using driver.quit() or driver.close(), getting the same error. "C:\Program Files (x86)\Python36-32\python.exe" D:/iqz/my-works/automation-practice/practice/selenium-tryout/firefoxSearch.py ImportError: sys.meta_path is None, ................Python is likely shutting down Process finished with exit code 0 – Vivek22 Jan 10 '17 at 03:10
  • Code used: from selenium import webdriver path1 = 'C:\Program Files (x86)\Python36-32\Lib\site-packages\selenium\webdriver\edge\MicrosoftWebDriver.exe' browser = webdriver.Edge(path1) browser.get("https://www.google.com/") – Vivek22 Jan 10 '17 at 03:12
3

you can also give time for the quit method to finish execution before python exit. this worked for me :

#right before quitting
driver.quit()
time.sleep(1)
JGauthier
  • 261
  • 3
  • 6
1

I have hit the same issue while working on CLI Automation project.

To get rid of this, you have to close the opened objects such as:

  1. If working on Paramiko, have to close the opened handlers client.close() shell.close()
  2. If working on file operations then file_handler.close()
  3. if working on sockets then we have close the objects created on it.
asr9
  • 2,440
  • 1
  • 21
  • 37