[英]Python selenium - Multiprocessing - How to close browser for an allocated process?
I know you can use driver.quit()
and driver.close()
but how to close nicely when executed multiple processes?我知道您可以使用
driver.quit()
和driver.close()
但是在执行多个进程时如何很好地关闭?
IDEAS:想法:
Using Selenium to end the WebDriver and Web Browser session graciously you should invoke the quit()
method within the tearDown() {}
.使用Selenium结束WebDriver和Web 浏览器session 您应该在
tearDown() {}
中调用quit()
方法。 Invoking quit() deletes the current browsing session through sending quit
command with {"flags":["eForceQuit"]}
and finally sends the GET
request on /shutdown
endpoint.调用quit()通过发送带有
{"flags":["eForceQuit"]}
的quit
命令删除当前浏览的 session,最后在/shutdown
端点发送GET
请求。 Here is the relevant log:以下是相关日志:
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
So on invoking quit()
method the Web Browser session and the WebDriver instance gets killed completely.所以在调用
quit()
方法时 Web 浏览器 session 和 WebDriver 实例被完全杀死。
You can find a couple of relevant detailed discussions in:您可以在以下位置找到一些相关的详细讨论:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.