Python木偶客户端不';不要关闭最后一个窗口

Python木偶客户端不';不要关闭最后一个窗口,python,firefox,firefox-os,firefox-marionette,Python,Firefox,Firefox Os,Firefox Marionette,这里有一个小程序,似乎没有关闭最后一个选项卡 来自提线木偶司机。提线木偶进口提线木偶 client = Marionette("localhost", socket_timeout=30, port=proc_port) client.start_session() client.set_window_size(1024,768) client.close() 这不会关闭最后一个选项卡,但如果有多个

这里有一个小程序,似乎没有关闭最后一个选项卡

来自提线木偶司机。提线木偶进口提线木偶

            client = Marionette("localhost", socket_timeout=30, port=proc_port)
            client.start_session()
            client.set_window_size(1024,768)
            client.close()
这不会关闭最后一个选项卡,但如果有多个选项卡,它将关闭一个选项卡

调用client.quit()将引发错误


如何关闭python木偶客户端的最后一个选项卡/窗口?

我将自己回答这个问题。在大量崩溃之后,我搜索了崩溃字符串,它使我在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()只能在木偶启动的壁虎上调用

然后我环顾四周,看到强制退出选项,所以我尝试了一下,它似乎杀死了最后一个Firefox窗口

也许将来Firefox团队可以解决这个问题,或者我可能用错了API

如果打开了多个选项卡,可以通过切换到该窗口句柄并调用该窗口句柄上的client.close()来关闭它

如果你只剩下一个标签打开了,那就不管用了,我不得不打电话给你

    client._send_message("quitApplication", {"flags": ["eForceQuit"]})

关闭最后一个窗口并退出。

我自己来回答这个问题。在大量崩溃之后,我搜索了崩溃字符串,它使我在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()只能在木偶启动的壁虎上调用

然后我环顾四周,看到强制退出选项,所以我尝试了一下,它似乎杀死了最后一个Firefox窗口

也许将来Firefox团队可以解决这个问题,或者我可能用错了API

如果打开了多个选项卡,可以通过切换到该窗口句柄并调用该窗口句柄上的client.close()来关闭它

如果你只剩下一个标签打开了,那就不管用了,我不得不打电话给你

    client._send_message("quitApplication", {"flags": ["eForceQuit"]})
关闭最后一个窗口并退出