sebastianbergmann/phpunit-selenium — Issue #80: stop() invoked from both SeleniumTestCase.php and Driver.php, results in ERROR: No sessionId provided
Author: edorian
Created: 2011-12-16 13:48:18+00:00
State: open

Not my bug. Moving this over from https://github.com/sebastianbergmann/phpunit/issues/276

-------------

Hi,

I have had problems with selenium test executions that rely on overriding stop() in classes that inherit from SeleniumtTestCase in order to perform some cleanup operations on the browsers used for the tests (clean cookies, etc,...).

It has happened in situations where some commands (waitForCondition(), for instance) can perfectly finish with a timeout. In this case, the remote selenium server returns something like the following:

12:04:01.803 INFO - Got result: Timed out after 30000ms, 'undefined' not found on session ab78cfc7fd1e41a0b1d026027e658338

But, as the method waitForCondition() is invoked through the doCommand() in Driver.php, and it considers any response that does not start with OK an error, the error handling part starts: it calls stop() on its own before launching a PHPUnit_Framework_Exception, so any other command executed after that point fails with something like:

ERROR: No sessionId provided. Most likely your original newBrowserSession command failed.

because that stop() invocation sends a testComplete command to selenium and nulls the session.

Removing the call to stop() in the doCommand() method of Driver.php fixes the problem.

The point here is that there seems to be a duplication between SeleniumTestCase.php and Driver.php, in that both of them may decide to stop a test, killing the selenium session, when it looks like SeleniumTestCase should be the only one with that responsibility/knowledge. I do not think the Driver should decide on suc a thing, but instead do the communication with selenium and report any error as an exception for the SeleniumTestCase to handle.

My 2 cents :)

Regards,
David