硒在-browserSessionReuse模式启动一个新的浏览器 [英] Selenium in -browserSessionReuse mode launchs a new browser

查看:167
本文介绍了硒在-browserSessionReuse模式启动一个新的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用-browserSessionReuse Selenium模式来加速我的测试,但我注意到了一个奇怪的行为。

这个模式的目的是避免时间浪费测试之间的开放浏览器,这是如何工作的。但并不总是,如果我连续运行测试,他们运行在相同的浏览器,正确的。但是如果在每次测试之间通过一些分钟,它会忘记它已经打开一个浏览器,并打开一个新的。

我想有一个超时丢弃老浏览器,但我不明白为什么。有没有反正要避免这个问题?

(用Selenium1和Selenium2测试)

在此先感谢

p>

Victor

解决方案

回答我自己的问题。
$ b

Selenium在-browserSessionReuse模式下缓存会话,以便在以下测试中再次使用会话,但在BrowserSessionFactory类中会有一个最大空闲会话时间到期:

  private static final long DEFAULT_CLEANUP_INTERVAL = 300000; // 5分钟。 
private static final long DEFAULT_MAX_IDLE_SESSION_TIME = 600000; // 10分钟

构造函数接收一个参数来执行清除,默认为TRUE。 (blf,DEFAULT_CLEANUP_INTERVAL,DEFAULT_MAX_IDLE_SESSION_TIME,true);然后,我们就可以使用这个函数来创建一个新的bs文件。

$ / code $


AFAIK没有办法使用Selenium参数来改变它,唯一的办法修改Selenium源代码并重新编译。所以,这就是我正在做的

I'm trying the -browserSessionReuse Selenium mode to speed up my tests but i've noticed a strange behaviour.

The purpose of this mode is avoid the time wasted opening browsers between tests, and this is how it works. But not always, if i run tests continuously they are run in the same browser, correct. But if between each test run pass some minutes, it will forget it has an already opened browser and it opens a new one.

I suppose there is a timeout to discard the "old" browser, but i don't understand why. Is there anyway to avoid this issue?

(tested with Selenium1 and Selenium2)

Thanks in advance

Victor

解决方案

Answering my own question.

Selenium caches the sessions in the -browserSessionReuse mode to reuse it again in the following tests, but they have a max idle session time to expire in the BrowserSessionFactory class:

private static final long DEFAULT_CLEANUP_INTERVAL = 300000; // 5 minutes.
private static final long DEFAULT_MAX_IDLE_SESSION_TIME = 600000; // 10 minutes

The constructor receives a param to do the cleanup which is TRUE by default.

public BrowserSessionFactory(BrowserLauncherFactory blf) {
        this(blf, DEFAULT_CLEANUP_INTERVAL, DEFAULT_MAX_IDLE_SESSION_TIME, true);
    }

AFAIK there is no way to change it using a Selenium param, the only way is modify the Selenium source code and compile it again. So, that's what i'm doing

这篇关于硒在-browserSessionReuse模式启动一个新的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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