Reputation: 45
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?
Upvotes: 1
Views: 2074
Reputation: 17658
The execution of the GetCookiesAsync
task needs to be awaited, like this:
private async Task YourMethod()
{
var result = await page.GetCookiesAsync();
}
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:
Id = 7315, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
is the async task not yet completed. GetCookiesAsync
returns immediately. If you want to want to wait for the result, you should await
it.
Upvotes: 2