0

"Hi, I'm trying to use selenium(Python) to perfrom some actions for me. The problem is; I want it to control a webpage that I have already opened and signed in to. I don't want it to go through the signing in procedure again and again which is very complicated. So is there a way I can control the webpage that is already opened and not opened by the driver itself?"

1 Answers1

1

use cookies or session for example You can save the current cookies as a python object using pickle.

import pickle
import selenium.webdriver 

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

then get them back

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("https://www.youtube.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    driver.add_cookie(cookie)
Ayoub Benayache
  • 1,046
  • 12
  • 28