有没有办法防止硒自动终止空闲会话? [英] Is there a way too prevent selenium automatically terminating idle sessions?

查看:122
本文介绍了有没有办法防止硒自动终止空闲会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用硒来自动进行与网站的某些交互.此过程涉及打开多个浏览器并使它们间歇执行操作.但是,偶尔会有很长的不活动时间(> 1小时),硒似乎在大约30分钟未被调用后会自动终止浏览器会话.

I am using selenium for automating some interactions with websites. This process involves opening several browsers and having them perform actions intermittently. However, occasionally there are long (> 1 hour) periods of inaction, and selenium seems to automatically kill browser sessions after ~30 minutes of not being called.

我想将此超时设置为7小时左右,但是我找不到任何方法.

I would like to set this timeout to 7 hours or so, but I cannot find any way of doing this.

这是硒发送的消息,它有助于关闭一个空闲的浏览器.

This is the message selenium sends as it helpfully closes an idle browser.

13:06:35.277 INFO [ActiveSessions$1.onStop] - Removing session 70a1b8cbae6876cde7e66df13b3942d1 (org.openqa.selenium.chrome.ChromeDriverService)

如果任何人有任何潜在客户,我将不胜感激.目前,我只是每15分钟刷新一次浏览器以防止超时,但是感觉很糟糕.

If Anyone has any leads I would be super grateful. At the moment I'm just auto-refreshing browsers every 15 minutes to prevent timeouts but it feels gross.

推荐答案

此错误消息...

INFO [ActiveSessions$1.onStop] - Removing session 70a1b8cbae6876cde7e66df13b3942d1 (org.openqa.selenium.chrome.ChromeDriverService)

...表示已启动/产生的新 Chrome浏览器会话已终止.

...implies that the already initiated/spawned a new Chrome Browser Session was terminated.

使用 Selenium Grid Hub/Node 配置和/或 RemoteWebdriver 实现可以观察到此问题.

This issue is observed with Selenium Grid Hub/Node configuration and/or RemoteWebdriver implementation.

如果您观察到selenium-server-standalone-x.y.z.jar-help,则默认值 -timeout/-sessionTimeout设置为 1800 秒.

If you observe the -help of selenium-server-standalone-x.y.z.jar the default -timeout / -sessionTimeout is set to 1800 seconds.

  • CLI命令:

  • CLI Command:

$>java -jar selenium-server-standalone-3.14.0.jar -help

  • 输出:

  • Output:

    -timeout-sessionTimeout:<Integer>(以秒为单位):指定在服务器自动终止最近X秒内没有任何活动的会话之前的超时时间.然后将释放测试插槽,以供其他测试使用.这通常用于照顾客户端崩溃.对于网格中心/节点角色,还必须设置cleanUpCycle.

    -timeout, -sessionTimeout: <Integer> in seconds : Specifies the timeout before the server automatically kills a session that hasn't had any activity in the last X seconds. The test slot will then be released for another test to use. This is typically used to take care of client crashes. For grid hub/node roles, cleanUpCycle must also be set.

    • 默认值:1800

      • Default value: 1800

        快照:

        因此,您会看到超时,并显示硒在被调用约30分钟后会自动终止浏览器会话.

        Hence, you see the time out and it appears selenium automatically kills the browser session after ~30 minutes of not being called.

        您可以按以下方式增加-timeout/-sessionTimeout:

        You can increase the -timeout / -sessionTimeout as follows:

        $>java -jar /path/to/selenium-server-standalone-3.14.0.jar -sessionTimeout 57868143
        

        这篇关于有没有办法防止硒自动终止空闲会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆