[英]Python selenium - Multiprocessing - How to close browser for an allocated process?
我知道您可以使用driver.quit()
和driver.close()
但是在執行多個進程時如何很好地關閉?
想法:
使用Selenium結束WebDriver和Web 瀏覽器session 您應該在tearDown() {}
中調用quit()
方法。 調用quit()通過發送帶有{"flags":["eForceQuit"]}
的quit
命令刪除當前瀏覽的 session,最后在/shutdown
端點發送GET
請求。 以下是相關日志:
1503397488598 webdriver::server DEBUG -> DELETE /session/8e457516-3335-4d3b-9140-53fb52aa8b74
1503397488607 geckodriver::marionette TRACE -> 37:[0,4,"quit",{"flags":["eForceQuit"]}]
1503397488821 webdriver::server DEBUG -> GET /shutdown
所以在調用quit()
方法時 Web 瀏覽器 session 和 WebDriver 實例被完全殺死。
您可以在以下位置找到一些相關的詳細討論:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.