Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: Do different browser instances have separate cookie jars?

Tags:

selenium

I'm trying to test a scenario where two separate users are logged in. As the question states, is this possible with Selenium? I don't if it's browser dependent, but I'm using Chrome.

like image 230
lairtech Avatar asked Sep 01 '13 18:09

lairtech


2 Answers

Selenium (web driver) allows to open several browser windows (e.g. 3 Firefox windows or 1 IE + 1 Firefox +1 Chrome).

In you code you have API to select the desired window (depending how on how you opened it).

Regarding the session handling: that depends on the browser type. Firefox will share the session across multiple windows because it's using a single process. AFAIK IE and Chrome if opened as new processes will not share it, but this of course depends also on how the server is setting the cookie policy for the session. Access to cookie values in the browser however is domain dependent, so a persistent cookies or local storage can share information even across sessions, so it really depends on how the web application is implemented (or what framework is using - that mostly takes care of such stuff).

like image 196
Hans Avatar answered Oct 19 '22 23:10

Hans


If you want complete separation, then take a look at Selenium Grid;https://code.google.com/p/selenium/wiki/Grid2

This would allow you to have the browsers open on different computers while running the test on one machine

like image 37
Robbie Wareham Avatar answered Oct 20 '22 00:10

Robbie Wareham