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

Options.getCookie should return null if cookie not found. #6292

Closed
AllenFang opened this issue Aug 16, 2018 · 5 comments
Closed

Options.getCookie should return null if cookie not found. #6292

AllenFang opened this issue Aug 16, 2018 · 5 comments
Labels

Comments

@AllenFang
Copy link

AllenFang commented Aug 16, 2018

Meta -

OS:

OSX 10.13

Selenium Version:

4.0.0-alpha.1

Browser:

Firefox developer edition

Browser Version:

62.0b15

Expected Behavior -

If cookie is not exists, I should get null just like official document said.
https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_Options.html

  • Retrieves the cookie with the given name. Returns null if there is no such cookie. The cookie will be returned as a JSON object as described by the WebDriver wire protocol.*

Actual Behavior -

I got an error:

    NoSuchCookieError: No cookie with name sbet

      at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:542:13)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:468:26)

Steps to reproduce -

I use Javascript and [email protected]

  1. Initialize Driver
  2. call await driver.manage().getCookie('XXX')
  3. I should got a null in step 2 but I got NoSuchCookieError.
@lmtierney
Copy link
Member

lmtierney commented Aug 16, 2018

The w3c spec says to throw the error you are getting, so that's at least behaving correctly. It looks like the getCookie command needs to add the NoSuchCookie error to the erros it catches here https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/lib/webdriver.js#L1207

@AllenFang
Copy link
Author

@lmtierney yes, I also checked the source code. So you mean the getCookie command need to return null instead of throw NoSuchCookie error? If yes, I probably can help to fix it.

@lmtierney
Copy link
Member

That's up to the maintainer of the nodejs code. If it's to be nil, then the code needs updating. If it's supposed to throw an error then the documentation needs updating. @jleyba

shs96c pushed a commit that referenced this issue Feb 27, 2020
@shs96c
Copy link
Member

shs96c commented Mar 3, 2020

@harsha509, thank you for fixing this!

@shs96c shs96c closed this as completed Mar 3, 2020
@lock
Copy link

lock bot commented Apr 2, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants