Thomas
Thomas

Reputation: 31

Selenium/PHPUnit: End a session when re-using browser sessions?

I'm runnig Selenium tests with PHPUnit.

I have some long test sequences split into several test files to make them easier to maintain. For higher speed I would like to re-use the browser session for these cases.

I am able to reuse the sessions (PHPUnit_Extensions_SeleniumTestCase::shareSession(true)), but I cannot figure out how to end the session and open a new one before starting the next tests (which require a fresh browser session).

I have tried using the following line in the tearDown() method of the test to kill the current browser session

$this->stop();

this kills the browser, but generates an error: "Session xxxxxx does not exist or was ended"

=> Exactly, but how do I get Selenium to start a new session in this case?

Thanks for any clues.

Upvotes: 3

Views: 3032

Answers (2)

Jochen
Jochen

Reputation: 1853

Try adding the

-browserSessionReuse

parameter when launching an Selenium RC node.

Upvotes: 0

faramka
faramka

Reputation: 2234

When I create a few tests method in my test class (test file), I don't use

$this->stop();
in tearDown() method. I noticed that at the end of each test, the browser simply closes itself. I just set browser and browser URL in setUp() method and I open it in every test method by using

$this->open('/');


Have you tried in this simple way?

Upvotes: 0

Related Questions