简体   繁体   中英

Is Phantomjs session isolation still not working?

When I run my selenium tests using a chrome browser all my tests cases run fine. When using the phantomjs browser it would appear that the browser session does not get reset after each test case. In my tests cases, I log in as a user to then navigate to certain pages and then logout. A problem occurs when a test case happens to fail. The browser session is not reset so when the next test case begins, the test that failed was unable to logout. This causes all test cases after a single failure to fail.

When searching the internet for a solution to this issue it been known sine 2013. I can't seem to find anything regarding this issue that's recent. Is there any up to date workarounds?

Manually trying to delete the cookies before or after each test case does not appear to work. webDriver.manage().deleteAllCookies();

I'm using phantomjs ver 2.1.1.

First of all PhantomJS is dead , you are better off switching to Headless Chrome or Headless Firefox .

Secondly PhantomJS is a port of Webkit which is not thread safe . This means that if you try and run more than one test in parallel you will see threading issues, to fix this you would need to start multiple instances of PhantomJS and have each GhostDriver instance connect to a different instance of PhantomJS.

The particular problem that you are seeing is that PhantomJS doesn't clear itself down properly, again the only solution would be to kill the initial PhantomJS instance you are running after your test finished and then start up a clean new one, unfortunately that is not supported by GhostDriver.

The final problem is that GhostDriver is dead as well, there was no point in continuing development when PhantomJS died.

TLDR; Use Chrome/Firefox Headless mode instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM