Search code examples
c#puppeteerwebautomationpuppeteer-sharp

Puppeteer Sharp submit form


I am trying to convert node.js code to C# and I am stuck at this point. I need to submit the form but I could not find any method in c#.

 await page.$eval('#my-form', form => form.submit()),

I could not find any function for $eval in C#. I have tried EvaluateExpressionAsync in C# but it seems like it executes our script inside the page. I do not want to trigger a click event on the button. I just want to translate that line of code in C#.


Solution

  • In puppeteer sharp that's being solved using extension methods.

    await page.QuerySelectorAsync("#my-form")
        .EvaluateFunctionAsync("form => form.submit()");