3

I want to use Selenium on a certain website. I have to open the website multiple times simultaneously with each instance having an unique session. I can open multiple windows but can't seem to create an unique session for each one.

I did some research and found Selenium Grid and some online platforms which can run all kinds of browsers to test your application but this seems to be more complicated than it has to be.

So how can I use Selenium to visit a website multiple times simultaneously with each one having an unique session?

Kind Regards,

Martin

  • which driver are you using? – Camilo Torres Aug 31 '15 at 00:45
  • Hi Camilo, i'm using Selenium Webdriver Chrome. – Martin Manfree Aug 31 '15 at 00:46
  • Can you paste the code you are using to initialize the webdriver and to connecto to the server? – Camilo Torres Aug 31 '15 at 00:55
  • Can you manually open two instances of Chrome on the same machine and get two unique sessions? If not, then using Selenium or Selenium Grid isn't going to fix that. Have you considered opening Chrome, FF, and IE to get different sessions? I'm assuming that would work but you would have to test that. – JeffC Aug 31 '15 at 00:56
  • You could also ask your devs how sessions are tracked on the site. It's possible that you could open the browser in Incognito mode to possible get around the session tracking. Just some thoughts... – JeffC Aug 31 '15 at 00:58
  • Thanks for your reactions. I can open for example one chrome window and one chrome private window. Or one chrome and one firefox window. This would achieve the result. Only I want to do it with more windows, thats why I'm trying to find a way in python. – Martin Manfree Aug 31 '15 at 01:13

1 Answers1

1

I once answered a similar question.

Selenium actually runs private mode by default. Every time you start any driver via Selenium it creates a brand new anonymous profile/session.

This means that you can instantiate multiple drivers, which will open multiple new windows and each of those should normally not be influenced by the others.

For instance the code:

from selenium import webdriver
import time

driver1 = webdriver.Firefox()
driver1.get("http://www.python.org")
driver2 = webdriver.Firefox()
driver2.get("http://www.python.org")
time.sleep( 20 )

will open 2 windows that are using different sessions. I used the sleep method, so you can see the windows visually.

Community
  • 1
  • 1
DJanssens
  • 17,849
  • 7
  • 27
  • 42