Python木偶客户端没有关闭最后的风

2024-04-26 05:35:27 发布

您现在位置:Python中文网/ 问答频道 /正文

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

从木偶_司机。木偶进口木偶

            client = Marionette("localhost", socket_timeout=30, port=proc_port)
            client.start_session()
            client.set_window_size(1024,768)
            client.close()

这不会关闭最后一个选项卡,但如果有多个选项卡,则会关闭一个选项卡。在

呼叫客户端.退出()将引发错误。在

如何从python maronette客户端关闭最后一个选项卡/窗口?在


Tags: 程序clientlocalhost客户端portsessiontimeoutsocket
1条回答
网友
1楼 · 发布于 2024-04-26 05:35:27

我自己去回答这个问题。在多次崩溃之后,我搜索了崩溃字符串,它引导我在mozilla开发网络上找到this file马里奥特.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

然后我环顾四周,看到了force quit选项,于是我尝试了一下,它似乎杀死了最后一个Firefox窗口。在

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

如果打开了多个选项卡,可以切换到该窗口句柄并调用客户端.close()在窗户把手上。在

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

^{pr2}$

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

相关问题 更多 >