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

一世执手 提交于 2019-12-12 16:00:06

问题


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.


回答1:


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?




回答2:


Try adding the

-browserSessionReuse

parameter when launching an Selenium RC node.



来源:https://stackoverflow.com/questions/8874241/selenium-phpunit-end-a-session-when-re-using-browser-sessions

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