Reputation: 882
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
Upvotes: 3
Views: 3826
Reputation: 57247
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'
.
Upvotes: 0
Reputation: 882
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
Upvotes: 5