0

I'm working on trying to automate a game I want to get ahead in called pokemon vortex and when I login using selenium it works just fine, however when I attempt to load a page that requires a user to be logged in I am sent right back to the login page (I have tried it outside of selenium with the same browser, chrome).

This is what I have

import time
from selenium import webdriver
from random import randint




driver = webdriver.Chrome(r'C:\Program Files (x86)\SeleniumDrivers\chromedriver.exe')  
driver.get('https://zeta.pokemon-vortex.com/dashboard/');
time.sleep(5) # Let the user actually see something!

usernameLoc = driver.find_element_by_id('myusername')
passwordLoc = driver.find_element_by_id('mypassword')

usernameLoc.send_keys('mypassword')
passwordLoc.send_keys('12345')

submitButton = driver.find_element_by_id('submit')
submitButton.submit()

time.sleep(3)

driver.get('https://zeta.pokemon-vortex.com/map/10')
time.sleep(10)

I'm using python 3.6+ and I literally just installed selenium today so it's up to date, how do I force selenium to hold onto cookies?

Joe
  • 269
  • 3
  • 13
  • Selenium doesn't hold on to the cookies itself, it just drives the browser (Chrome), which should handle the cookies automatically. Out of curiosity, do you have the same problem if you use Firefox with Selenium? – Will Keeling Aug 26 '18 at 10:58
  • I'm not sure, I don't use firefox. Regardless I managed to fix it after I changed the value of the $cdc variable as per here: https://stackoverflow.com/questions/33225947/can-a-website-detect-when-you-are-using-selenium-with-chromedriver – Joe Aug 26 '18 at 11:00
  • Also I hadn't realized that when you close the selenium browser the actual drivers do not close, so it may have been a multilogging issue. – Joe Aug 26 '18 at 11:01

1 Answers1

0

Using a pre-defined user profile might solve your problem. This way your cache will be saved and will not be deleted.

from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data")
driver = webdriver.Chrome(options=options)
driver.get("xyz.com")
Coder7
  • 61
  • 1
  • 1
  • 2