Continuing a session using SessionId

351 views
Skip to first unread message

Mohan Radhakrishnan

unread,
Dec 19, 2017, 8:24:19 AM12/19/17
to Selenium Users
Hi,

Is there a way to associate a new WebDriver with an existing session ID so that the earlier Web page 'login' is continued ? I am assuming here that the 'login' cookies
will be reused for the new driver. 

SessionId session = ((RemoteWebDriver)ieDriver).getSessionId();

Thanks,
Mohan

Mohan Radhakrishnan

unread,
Dec 20, 2017, 5:51:26 AM12/20/17
to Selenium Users

I tried to get the cookies in the hope that the IE driver can use it but I see this error.

Exception org.openqa.selenium.WebDriverException: Could not retrieve cookies. The most common cause of this error is a mismatch in the bitness between the driver and browser. In particular, be sure you are not attempting to use a 64-bit IEDriverServer.exe against IE 10 or 11, even on 64-bit Windows. 

Is this  a known issue ?

Thanks,
Mohan

⇜Krishnan Mahadevan⇝

unread,
Dec 20, 2017, 6:01:13 AM12/20/17
to Selenium Users
Mohan,
I dont think thats how it works.

Here's my understanding.
The SessionId in the Selenium world is not the same as the SessionId as used in a typical web application context.

Selenium basically uses the SessionId to associate/identify as to which server process should the client be talking to. The client could either be your tests or it could be a Selenium node, which receives a new session request from the Hub.

If you would like to spin off a new browser (powered by webdriver) which wants to re-use an existing application session (Not the webdriver session), then all you need to do is to export the set of cookies from your first session, persist it in memory, and then once your new browser comes up via webdriver instantiation, you inject those cookies into the new instance. 

You might have to open up the corresponding web page, prior to doing this. I am not sure on that part, because I have never done it.

But driver.getSessionId() has got no role to play in this entire exercise.

In terms of the error you are facing, you would need to add some details pertaining to what version were you working with for Selenium/IEDriverServer/EdgeDriver/Browser version etc., and also furnish a sample test that could be executed to reproduce the problem that you are seeing!

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a25f369b-1264-4fcf-9f2e-32f0a7ca54ea%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mohan Radhakrishnan

unread,
Dec 20, 2017, 9:17:10 AM12/20/17
to Selenium Users
Krishnan,

                  I realize that there is a difference between the session ID's. I was thinking that this session ID is significant enough to make selenium
use my browser window that is already open. And by doing that it may use my 'login' cookies and allow me to continue. Does that make sense ?

If it is the same browser window then the 'login' session is still valid.


Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

⇜Krishnan Mahadevan⇝

unread,
Dec 20, 2017, 9:23:53 AM12/20/17
to Selenium Users

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Dec 20, 2017 at 7:47 PM, Mohan Radhakrishnan <radhakris...@gmail.com> wrote:
Krishnan,

                  I realize that there is a difference between the session ID's. I was thinking that this session ID is significant enough to make selenium
use my browser window that is already open. And by doing that it may use my 'login' cookies and allow me to continue. Does that make sense ?

​[Krishnan] When you say browser window that is already open, what do you mean ? Is a new browser window that you opened about which selenium has no knowledge whatsoever (or) does is it a new browser window that selenium opened up, wherein you are just trying to port your application's session into this browser ? If its the former, then am afraid AFAIK, its not possible. In order for selenium to interact with a browser, it has to be spun off by the server component. I dont think you can have the server component [ chromedriver/geckodriver/iedriverserver/edgedriver] to attach itself to a browser that is already open i.e., attaching to an existing ProcessId of a browser.​

And no its still not clear, as to what you are trying to solve, at-least not to me! 
So it would be good if you could please help rephrase the problem statement.
 
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/720041b2-73a3-4342-a576-bf3abe756298%40googlegroups.com.

Mohan Radhakrishnan

unread,
Dec 20, 2017, 11:29:02 AM12/20/17
to Selenium Users

  Selenium opened the browser window. I close the driver and open a new driver. Unfortunately the selenium code is executed by another tool. So I couldn't show that.

Thanks.
Reply all
Reply to author
Forward
0 new messages