2016-03-01 26 views
0

似乎這個bug在Phantom JS版本2.48中出現過,但我不明白爲什麼它出現在舊版本(穩定版本)中正在使用。無法退出PhantomJS,windows 7. Phantom JS版本2.1.1

這是一個非常類似的問題。

How to properly stop phantomjs execution

但這裏是我的代碼,並且錯誤它拋出

from selenium import webdriver 

driver = webdriver.PhantomJS() # or add to your PATH 
driver.set_window_size(1024, 768) # optional 
driver.get('https://google.com/') 

driver.close() 
driver.quit() 

伊夫單獨和共同使用這兩種.close()和.quit()。 close()似乎可以自行工作,但實際上並沒有停止phantomjs進程。

driver.quit()給我的錯誤

Traceback (most recent call last): 
    File "C:\Python27\test.py", line 9, in <module> 
    driver.quit() 
    File "C:\Python27\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 74, in quit 
    self.service.stop() 
    File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 124, in stop 
    self.process.stdout.close() 
AttributeError: 'NoneType' object has no attribute 'close' 

任何意見或建議將是巨大的。 謝謝!

編輯:我也嘗試重新啓動作爲這裏所說Selenium webdriver + PhantomJS processes not closing

回答