question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get Cookies keyword will fail if the Selenium get_cookie method return value contains more keys than: name, value, path, domain, secure, httpOnly and expiry

See original GitHub issue

Selenium get_cookie returns a dictionary. If the dictionary contains more keys then the name, value, path, domain, secure, httpOnly and expiry, then the Get Cookies keyword will fail:

20190212 16:54:43.113 :  FAIL : TypeError: __init__() got an unexpected keyword argument 'hCode'
20190212 16:54:43.113 : DEBUG :
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\SeleniumLibrary\__init__.py", line 369, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "C:\Python27\lib\site-packages\SeleniumLibrary\base\robotlibcore.py", line 102, in run_keyword
    return self.keywords[name](*args, **kwargs)
  File "C:\Python27\lib\site-packages\SeleniumLibrary\keywords\cookie.py", line 99, in get_cookie
    return CookieInformation(**cookie)

This is because the Get Cookies keywords has hard coded keys what Selenium response can contain in the CookieInformation object. The limitation has been in place since the SeleniumLibrary 3.0 release, but there was issue reported in Slack, that for that particular user, Selenium get_cookie did return the following:

{u'domain': u'1.2.3.4', u'name': u'components_state', u'value': u'alsdjaslkdjasdlkj', u'path': u'/', u'hCode': -1693023704, u'class': u'org.openqa.selenium.Cookie', u'httpOnly': False, u'secure': False}

SeleniumLibrary should not fail, if the Selenium get_cookie returns more keys that is specified . Instead we should allow extra keys to be passed to the CookieInformation object and allow access to the extra keys in similar way as the specified keys.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aaltatcommented, Feb 16, 2019

@vyvital this issue should be fixed. Could you install from master and give it a try?

0reactions
aaltatcommented, Feb 17, 2019

Ah, very good point, will make the changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when loading cookies into a Python request session
The Cookie HTTP request header contains stored HTTP cookie previously sent by the server with the Set-Cookie header. A HTTP cookie is a...
Read more >
Cookies Handling in Selenium WebDriver - Guru99
It stores information using a key-value pair. ... with a name, value, domain, path, expiry, and the status of whether it is secure...
Read more >
How To Handle Cookies in Selenium WebDriver - Medium
Value — This field contains the cookie's value. Domain — This field contains the hosts that are allowed to receive the cookie. Path...
Read more >
SeleniumLibrary - Robot Framework
SeleniumLibrary is a web testing library for Robot Framework. This document explains how to use keywords provided by SeleniumLibrary.
Read more >
http.cookiejar — Cookie handling for HTTP clients — Python ...
Source code: Lib/http/cookiejar.py The http.cookiejar module defines classes for automatic handling of HTTP cookies. It is useful for accessing web sites ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found