Yash Nigam
Yash Nigam

Reputation: 1

Selenium driver.get_cookies() is returning empty list []

I used Selenium to successfully log in to a portal. However, when attempting to extract cookies, I received an empty list. Interestingly, I noticed the cookies are visible in the network tab but are hidden under "Show filtered cookies." Inside network request we can see this cookie section

I attempted to extract cookies from various endpoints, but every attempt resulted in an empty list. I also tried retrieving cookies using the script execution method:

cookies = driver.execute_script("return document.cookie")

Can anyone help debugging get those cookies?

Upvotes: 0

Views: 149

Answers (1)

khosro
khosro

Reputation: 1

chrome_option = webdriver.ChromeOptions() chrome_option.add_argument('user-data-dir=cookies') driver = webdriver.Chrome(chrome_option)

The get_cookies() method doesn't work at all for me either. You can use this, it saves all browser cookies, including photos, videos and everything.

In order to use it, you have to put this first, then check if there are words like (login. signup...) on the login page, if is there, then log in first.

Upvotes: 0

Related Questions