stevepryde/thirtyfour

How to call with cookie ?

anhduca4 opened this issue · 6 comments

I want to call to url with cookie . But I saw it not have cookie ? Can you help me for it ?

Hi, I'm not sure if this is possible with selenium. You can add cookies to the current session (see here) and get the cookies from the browser, but I'm not sure what you mean by "call to url with cookie". Can you provide more info?

My solution is . In my browser after login in my website I will have cookie . Then I want use this cookie no need login again.

Selenium will automate the browser session in much the same way as a user using the browser. You shouldn't need to do anything special for the cookie to be stored in that browser session. However, each time you start a new browser session via selenium you will need to login again. I don't think there's a way around that. The reason is because both chrome and firefox will create a new profile for that session, which you can think of similar to incognito mode. Once the session ends, all the cookies for that session (and everything else for that profile) will be deleted.

It might be possible to save the cookie details to disk and then add it back into the browser next time (the example I mentioned before has code for adding a cookie to the browser), but I'm not sure about this. Is it definitely using cookies and not local storage? You can access local storage using javascript. You can probably access cookies with JS too, although selenium has built-in cookie support so that shouldn't be necessary.

If you're trying to do multiple tests or things requiring login, probably the best solution is just to automate the login step so that it's automatic and quick.

Thankyou for suport.

You're welcome. Hope you can get it all working.