Setting Cookies to the test HttpClient in WebApplicationFactory #63371
-
Hello, Is there any way I can set a cookie to the test httpclient created from Background I am trying to implement end to end testing of a Blazor application using playwright. For this, I am following an idea introduced in a community stand up by @MackinnonBuck where he intercept requests and send them to the test http client created by Our application needs a cookie attached for this to work and even though I can configure the cookie in the Playwright BrowserContext, I am not able to pass that onto the Blazor app. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can yes, you just need to pass a cookie handler through when creating the HttpClient. For example: using var cookieHandler = new CookieContainerHandler();
using var client = Fixture.CreateDefaultClient(cookieHandler); |
Beta Was this translation helpful? Give feedback.
You can yes, you just need to pass a cookie handler through when creating the HttpClient.
For example: