1

I'm using selenium for the past 1 month. I want to create some small applications using selenium. Selenium webdriver opens an incognito window when I run it. Is there any way to make it launch in normal window(i.e which has my accounts logged in)?

This is the code which I'm using : (python code in linux)

chromedriver = Path to chrome driver
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.get("http://www.gmail.com")
Sai Krishna
  • 39
  • 1
  • 7
  • By default webdriver will launch Chrome in normal window. Can you describe what settings you use to launch Chrome? When you say Incognito mode, do you mean the Chrome Incognito mode which uses Dark Grey window frame with a detective image on the top left corner? Or you mean the browser was launched without the login cookies? – userpal Jul 15 '14 at 10:02
  • Maybe this issue is related : http://stackoverflow.com/questions/14480717/load-chrome-profile-using-selenium-webdriver – singe3 Jul 15 '14 at 10:02
  • @Patrik It is launching in a window which doesn't have any extensions or login cookies. Sorry for the delay – Sai Krishna Jul 15 '14 at 11:36

1 Answers1

0

If you want to re-use your login/authentication cookies, you can save the cookies and then load it again.

You can refer to this post:

To save cookies:

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))

To add back the cookies:

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    driver.add_cookie(cookie)

If you want to load an extension when Chrome starts, you can refer to this post and this post.

Community
  • 1
  • 1
userpal
  • 1,483
  • 2
  • 22
  • 38