You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
#1307
Closed
aaltat opened this issue
Feb 12, 2019
· 5 comments
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:
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.
The text was updated successfully, but these errors were encountered:
Found more about 'hCode' and 'class' here nightwatchjs/nightwatch#470 and SeleniumHQ/selenium-google-code-issue-archive#1227
I noticed when im using my browser trying to reach google.com it returns : {u'domain': u'.google.com', u'secure': False, u'value': u'158=Q_smyAojkcCcMosB0O-z8SB6SZfYsJj8QQu9CV5R2CejUPUaBdVbndAvRi0tNAZActD_tdPs_McMnuuKJ6QCE8n3Xt8fP8EeRKe3SpbA7ghZYKA5u3wmtFHSOpYgS-MP11W4lA5EvG3NqTWTl3jXVtl-s4Rj71KbrfbZ4qeVX6s', u'expiry': 1565866084.894618, u'path': u'/', u'httpOnly': True, u'name': u'NID'}
But when using a remote connection such as Browserstack service I get {u'domain': u'.google.com', u'name': u'NID', u'value': u'158=e2cyaJdHpNrgWpildw2PFvy0Oa4jxdv4axq8_HUw5PMBlU7-cnllxdS6u9BcfnCC7BBBtCMzIcp6zctnb5g0QRBK4bHgrnIwCdrw7-fxCqW2dyvOCgMeRhFEoMP9ItGA0i2e-xP-B1kcYWSAXct_Nlvnac6m6JrPQu_ilKgXkC4', u'expiry': 1565866484, u'path': u'/', u'hCode': 77289, u'class': u'org.openqa.selenium.Cookie', u'httpOnly': True, u'secure': False}
So BrowserStack adds some attributes to the cookie, interesting. No idea why it's done, but I guess they have their reasons. In any case, it's not hard to fix, would you @vyvital be interested providing a pull request?
Selenium get_cookie returns a dictionary. If the dictionary contains more keys then the
name
,value
,path
,domain
,secure
,httpOnly
andexpiry
, then the Get Cookies keyword will fail: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: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 theCookieInformation
object and allow access to the extra keys in similar way as the specified keys.The text was updated successfully, but these errors were encountered: