我会继续自己回答这个问题。在多次崩溃之后,我搜索了崩溃字符串,它引导我找到了 mozilla 开发网络上的 mariontte.py文件
浏览代码我看到了这些行
@do_process_check
def quit(self, in_app=False):
"""Terminate the currently running instance.
This command will delete the active marionette session. It also allows
manipulation of eg. the profile data while the application is not running.
To start the application again, start_session() has to be called.
:param in_app: If True, marionette will cause a quit from within the
browser. Otherwise the browser will be quit immediately
by killing the process.
"""
if not self.instance:
raise errors.MarionetteException("quit() can only be called "
"on Gecko instances launched by Marionette")
我一直在崩溃quit() can only be called on Gecko instanced launched by Marionette
然后我环顾四周,看到了强制退出选项,所以我尝试了一下,它似乎杀死了最后一个 Firefox 窗口。
也许将来 Firefox 团队可以解决这个问题,或者我可能使用错误的 API。
如果您打开了多个选项卡,您可以通过切换到该窗口句柄并在该窗口句柄上调用 client.close() 来关闭它。
如果您只打开一个标签,那将不再有效,对我来说,我不得不打电话
client._send_message("quitApplication", {"flags": ["eForceQuit"]})
关闭最后一个窗口并退出。