keep logged selenium

Solutions on MaxInterview for keep logged selenium by the best coders in the world

showing results for - "keep logged selenium"
Callan
17 Aug 2020
1#saving cookies
2
3
4import pickle 
5from selenium import webdriver 
6
7
8driver = webdriver.Firefox() 
9driver.get('http://www.quora.com') 
10# login code 
11pickle.dump(driver.get_cookies() , open("QuoraCookies.pkl","wb")) 
12
13
14#loading cookies
15
16
17import pickle 
18from selenium import webdriver 
19
20
21driver = webdriver.Firefox() 
22driver.get('http://www.quora.com') 
23for cookie in pickle.load(open("QuoraCookies.pkl", "rb")): 
24    driver.add_cookie(cookie)