I need to get cookies of particular website from puppeteer chrome session and add these cookies to script.Here is code I am doing to get cookies form page:
page.GetCookiesAsync();
But it return:
Id = 7315, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
Other way I have tried:
page.Client.SendAsync("Network.getAllCookies");
Both methods not working for me. What I am doing wrong?
The execution of the
GetCookiesAsync
task needs to be awaited, like this:You might need to change your callers for this.
Try to read about asynchronous programming in C#: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/
So what you are seeing with this:
is the async task not yet completed.
GetCookiesAsync
returns immediately. If you want to want to wait for the result, you shouldawait
it.