Search code examples
c#puppeteerpuppeteer-sharp

Why do I get an error when I run StealthPlugin in PuppeteerSharp?


I'm trying to run the StealthPlugin plugin in PuppeteerSharp. But I keep getting the error: method not found "System.Threading.Tasks.Task PuppeteerSharp.IPage.EvaluateExpressionOnNewDocumentAsync(System.String)" Although the browser starts. Please tell me how to solve this problem.

   var extra = new PuppeteerExtra(); 
   extra.Use(new StealthPlugin());

   // Launch the puppeteer browser with plugins
   var options = new LaunchOptions()
   {
       Headless = false,
       ExecutablePath = @"C:\Program Files\Google\Chrome\Application\chrome.exe"

   };
   var browser = await extra.LaunchAsync(options); // ERROR HERE

   // Create a new page
   var page = await browser.NewPageAsync();

   await page.GoToAsync("http://google.com");

   // Wait 2 second
   await page.WaitForTimeoutAsync(2000);

   // Take the screenshot
   await page.ScreenshotAsync("extra.png");

Solution

  • This just happened to me too. I don't know why this error occures but I resolved it by degrading PuppeteerSharp to version 15.0.0.