Implement Session Isolation #170

Closed
akoumjian opened this Issue Jan 25, 2013 · 18 comments

Comments

Projects
None yet

This feature is quite important.

A running PhantomJS process, currently, shares the same CookieJar across multiple WebPage.
While this is the correct behaviour in a normal browser (i.e. if you open 2 tabs on www.examplemail.com and log in in one of them, you will log in in the other as well).

We need PhantomJS to support the option to create a WebPage with a new, fresh, independent CookieJar.

This work will require intervention on both GhostDriver & PhantomJS codebase.


Original Title was: Unique sessions not being treated as such?
Pardon if I am mistaken, as I'm new to ghostdriver / selenium.

I came across this problem when I noticed that my (python) client was using old sessions, even after quitting the client instance and restarting it. I tried using driver.start_session(), which changed the driver.session_id but as far as I could tell it was being treated as the same session (ie: I was still authenticated as a user). Also tried deleting cookies, but it was reporting that none were to be found.

The client is correctly using new sessionId in its POST request over the Wire.

If I restart the phantomjs --webdriver instance, the session clears out properly.

Owner

detro commented Jan 25, 2013

Hi,
Currently there is a limitation in PhantomJS that doesn't allow to separate cookiejar across sessions in the same Phantomjs process instance.

I don't remember if it's there already, but if not could you please file an issue to develop this feature?

In the meantime though don't despair: you could use Python bindings and create a new Driver instance every time. That takes care of staring a new phantomjs instance every time for you.

Owner

detro commented Jan 25, 2013

I have actually converted this story.

Thanks

What would be your suggested route? Are there python bindings for phantomjs
to start/stop the process, Or do I just make a call to the shell?

Thanks for the response and for filing the ticket.
Sent from my mobile.

On Jan 25, 2013, at 5:09 AM, Ivan De Marino notifications@github.com
wrote:

Hi,
Currently there is a limitation in PhantomJS that doesn't allow to separate
cookiejar across sessions in the same Phantomjs process instance.

I don't remember if it's there already, but if not could you please file an
issue to develop this feature?

In the meantime though don't despair: you could use Python bindings and
create a new Driver instance every time. That takes care of staring a new
phantomjs instance every time for you.


Reply to this email directly or view it on
GitHubhttps://github.com/detro/ghostdriver/issues/170#issuecomment-12700059.

Owner

detro commented Jan 25, 2013

The current Python PhantomJSDriver bindings should create a new process for every new PhantomJSDriver object.

Contributor

garyd203 commented Jan 29, 2013

@detro Note that we had some discussion on this topic a while ago in #90, in case that is helpful.

jroper commented Oct 29, 2013

Another area to consider for session isolation is the fs module - changeWorkingDirectory changes the working directory for all sessions. Of course, this will require support in webdriver itself unless ghostdriver starts a new process for each session.

The use case for this is using phantomjs/ghostdriver as a server for sending build commands.

stof referenced this issue in minkphp/MinkSelenium2Driver Dec 7, 2013

Merged

Added testing with the phantomjs webdriver implementation #96

detro was assigned Jan 1, 2014

detro referenced this issue in ariya/phantomjs Jan 5, 2014

Closed

Cookiejar module #11535

Owner

detro commented Jan 12, 2014

I'm currently working on adding support to the new "multi-cookiejar" feature of PhantomJS (that has just landed).

detro closed this in e401410 Jan 12, 2014

stof commented Feb 5, 2014

@detro when will this be available in PhantomJS ?

altryne commented Mar 13, 2014

👍 I'm also very interested to know this, as currently it breaks our selenium tests, that treat every test as a clean browser

ghostdriver 1.1.1 is already in phantomjs's master branch (1.10.0-dev). I built a .deb package for ubuntu 12.04. As a quick test, I ran behat and found many features failing that previously passed with selenium+firefox. If anyone else is interested in trying it out:

https://dl.dropboxusercontent.com/u/109363425/phantomjs_1.10.0instaclick1_amd64.deb

stof commented Mar 26, 2014

@robocoder is there more failures than when running it against PhantomJS 1.9.7 (see the Travis builds) ? If yes, it could indicate some regression in either PhantomJS 1.10 or GhostDriver 1.1.1

FYI: Ghostdriver 1.1.1, and hence also the fix for this issue, is not in any released PhantomJS versions as of today. PhantomJS 1.9.6 included Ghostdriver 1.1.1 but this was never working. So PhantomJS 1.9.7 reverted to Ghostdriver 1.1.0.

Whats the current status of this issue? Session/context isolation is imperative for running our Behat tests so this is pretty important :)

Owner

detro commented Jun 19, 2014

The code on the GhostDriver side is part of 1.1.1.

That hasn't been released inside PhantomJS yet.
You gotta build PhantomJS master for this.

That said, all the (little!) energy this community can summon in terms on contributions is focused on pushing PhantomJS 2 out.
So, for 1.x you have to compile it yourself.
For 2.x... soon...

I need a new feature 'Session/context isolation' and
I try to build PhantomJS from master.
But I got error:
"icu.cpp:42:28: fatal error: unicode/utypes.h: No such file or directory"
I need an assistance.

CL0SeY commented Oct 27, 2014

Try installing libicu-dev
You may need all these dependencies as listed here:
https://github.com/ariya/phantomjs/wiki/PhantomJS-2

sudo apt-get install libsqlite3-dev ruby gperf bison flex libfontconfig1-dev libicu-dev fontconfig libssl-dev

So what's the recommended way to get this functionality right now? Doesn't seem to be there with 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment