Skip to content

A command response was not received #5

@hejiheji001

Description

@hejiheji001

Hi, I was using this function to execute JS in the page.

public static async Task<string> EvalJSByContextIdAsync(ChromeSession session, long executionContextId, string javaScriptStr)
{
    await s.WaitAsync();
    var evaluateResponse = await session.Runtime.Evaluate(new Runtime.EvaluateCommand
    {
        AwaitPromise = false,
        Expression = javaScriptStr,
        IncludeCommandLineAPI = true,
        ContextId = executionContextId,
        ObjectGroup = "ChromeDevProtocolWrapper"
    });
    await session.Runtime.Enable(new Runtime.EnableCommand());
    s.Release();
    return evaluateResponse.Result.Value.ToString();
}

I will get A command response was not received:Runtime.evaluate error when I call this function more than once.

var check = await CDP.EvalJSByContextIdAsync(session, executionContextId, checkScript);
while (check.Equals("False"))
{
    Thread.Sleep(5000);
    Console.WriteLine("Sleep");
    check = await CDP.EvalJSByContextIdAsync(session, executionContextId, checkScript); //Error here
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions