Closed badr-elmazaz closed 2 years ago
webdriver.get_cookies()
and webdriver.add_cookie(cookie)
are Selenium functions - they are not specific to Selenium Wire. Cookies are just HTTP headers, so to debug what is going on you could try examining the headers of the requests captured by Selenium Wire for amazon.com - e.g.
for request in driver.requests:
if request.host.endswith('amazon.com'):
print('Cookie: ', request.headers['Cookie'])
Thanks wkeeling I did not know that those functions dont work in selenium wire. I fixed the problem using an interceptor that adds the Cookie header for each request. Good job for this fantastic library. Have a nice day.
I am trying to get cookies of a webpage and I am using selenium wire. So i made a simple workaround getting all the responses and extract the set cookie header, but when I geth them and I try to inject this cookies into another webdriver session it does not work, cookies are not set. This is the function to get the webdriver:
When it opens the browser an I try to go to a website like amazon.com and I try to use
webdriver.get_cookies()
it returns empty list but if I inspect that webpage and I go to console and I typedocument.cookie
in the browser opened it returns that there are cookies. I also have problems injecting cookies usingwebdriver.add_cookie(cookie)
it doesn t work. What am I wrong? Thanks previously for the help.