Selenium in -browserSessionReuse mode launchs a new browser

孤人 提交于 2019-12-06 01:54:10

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

To share browser sessions in Selenium2TestCase, you must set sessionStrategy => 'shared' in your initial browser setup:

public static $browsers = array(
    array(
        '...
        'browserName' => 'iexplorer',
        'sessionStrategy' => 'shared',
        ...
    )
);

The alternative (default) is 'isolated'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!