Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyword to get all cookie information #932

Closed
pekkaklarck opened this issue Sep 28, 2017 · 6 comments
Closed

Add keyword to get all cookie information #932

pekkaklarck opened this issue Sep 28, 2017 · 6 comments

Comments

@pekkaklarck
Copy link
Member

We currently have Get Cookie Value but it only returns the value, not other information such as expiry. We have few possibilities how this could be implemented:

  1. Enhance the existing Get Cookie Value to allow returning other info too. For backwards compatibility reasons its default behavior cannot change, but it could get a new optional argument like info='value' that could be used like this:

     ${value} =    Get Cookie Value    name
     Log    ${value}
     ${expiry} =    Get Cookie Value    name    info=expiry
     Log    ${expiry}
    
  2. Add separate new keyword like Get Cookie or Get Cookie Information that returns a custom object containing all cookie information in its attributes. This info could then be used in the data easily:

     ${cookie} =    Get Cookie    name
     Log    ${cookie.value}
     Log    ${cookie.expiry}
    
  3. Enhance the existing Get Cookie Value to return an object with all the cookie information.

My favorite is option 2. If we decide to do that, then we could consider deprecating the existing Get Cookie Value. We should also think what to do with the current Get Cookies which returns a string in format cookie1=value1; cookie2=value2. It should rather return a list of cookie objects, but that change would be backwards incompatible. I have an idea how it could be deprecated pretty gracefully, though.

@pekkaklarck
Copy link
Member Author

I add this into SL 3.0 rc 1 scope because some kind of a way to get the expiry value would be needed by #891. If adding a new object and deprecations it would require is too much work, we can in SL 3.0 simply enhance the existing Get Cookie Value.

@aaltat
Copy link
Contributor

aaltat commented Sep 28, 2017

I think that option 2 would be best but it might be challenging to do in the 3.0 scope. Then doing the option 1 would be nice.

@pekkaklarck
Copy link
Member Author

One thing to decide, regardless how we decide to return the information, is how to represent the expiry time. Apparently browsers store them in seconds (since EPOCH?) except for Safari that uses milliseconds. We should always use the same format, regardless the browser, and I don't think a plain integer (or float) is the best representation.

Probably the best idea would be using Python's standard datetime object. They have useful attributes that can be accessed in data like ${expiry.year} and they are fully supported also by Robot's own DateTime library. Regardless the format we use, the same format should be accepted as an input when setting the expiry time (#891).

@aaltat
Copy link
Contributor

aaltat commented Sep 28, 2017

I don't have knowledge how the expiry date of the cookie is stored. Is it possible that other formats than epoch is supported? By quickly googling it looks like that: https://stackoverflow.com/questions/6556930/python-persistent-cookie-generate-expires-field and
https://en.m.wikipedia.org/wiki/HTTP_cookie

@aaltat
Copy link
Contributor

aaltat commented Oct 5, 2017

Done in #930

@aaltat aaltat closed this as completed Oct 5, 2017
@pekkaklarck
Copy link
Member Author

Attributes provided by the returned object should be documented. Using a table for attributes and adding some usage examples similarly as with Process library's Result object ought to work well.

Should also add a note that this keyword was added in SL 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants