简体   繁体   中英

Selenium Hub Chrome Node does not get HttpOnly Cookies

I am running Selenium tests in two ways:

  1. locally with Chrome WebDriver, for implementing the tests
  2. in a CI-pipeline with Selenium Hub and a Chrome Node, to run the tests

The backend creates HttpOnly cookies. I want to check their existence. To get a specific cookie I use the following code:

driver.Manage().Cookies.GetCookieNamed("CookieFooBar");

This works perfectly with the Chrome WebDriver, but does not work with the Chrome Node. Any ideas, what might cause this different behavior?

The answer to this problem is already inside the question itself. As the cookies are HttpOnly cookies, the browser can't track their existence - nevertheless they are still existing. This is actually the reason the HttpOnly flag was created for.

For testing purposes it might be a better approach to test the functionality the cookies should provide instead of simply checking their existence.

I ran the Chrome WebDriver tests without a docker-compose, which I did in the CI-pipeline. That is why the browser was not able to see the HttpOnly cookies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM