Overmiind / Puppeteer-sharp-extra

Plugin framework for PuppeteerSharp
MIT License
187 stars 53 forks source link

Stealth and BlockResources plugins is not working with PuppeteerSharp 15.1 #60

Open Vicher opened 8 months ago

Vicher commented 8 months ago

Using PuppeteerExtraSharp 2.0.0 with PuppeteerSharp 15.1.0 causes an exception.

Code:

static async Task Main(string[] args)
{
    await new BrowserFetcher().DownloadAsync();

    var extra = new PuppeteerExtra();
    var options = new LaunchOptions
    {
        Headless = false,
        DefaultViewport = new ViewPortOptions
        {
            Width = 1920,
            Height = 969
        },
        IgnoredDefaultArgs =
        [
            "--enable-automation"
        ],
        Args = [
            "--useAutomationExtension=false",
            "--disable-infobars",
            "--window-size=1920,1080",
        ]
    };

    extra.Use(new StealthPlugin());

    await using var browser = await extra.LaunchAsync(options);
    await using var page = (await browser.PagesAsync()).First();

    await page.GoToAsync("https://bot.sannysoft.com");

    await Task.Delay(60_000);
}

Causes an exception:

Unhandled exception. System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task PuppeteerSharp.IPage.EvaluateExpressionOnNewDocumentAsync(System.String)'.
   at PuppeteerExtraSharp.Plugins.ExtraStealth.StealthPlugin.OnPageCreated(IPage page)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at PuppeteerExtraSharp.Plugins.ExtraStealth.StealthPlugin.OnPageCreated(IPage page)
   at PuppeteerExtraSharp.PuppeteerExtra.Register(IBrowser browser)
   at PuppeteerExtraSharp.PuppeteerExtra.OnStart(BrowserStartContext context, IBrowser browser)
   at PuppeteerExtraSharp.PuppeteerExtra.LaunchAsync(LaunchOptions options)
   at PuppeteerSharpTest.Program.Main(String[] args) in D:\src\CSharp\PuppeteerSharpTest\PuppeteerSharpTest\Program.cs:line 38
   at PuppeteerSharpTest.Program.<Main>(String[] args)

BlockResourcesPlugin has similar issue.

warmfire540 commented 8 months ago

@Vicher remove any references you have to Puppeteer and let nuget pull in the correct ones

Vicher commented 8 months ago

@Vicher remove any references you have to Puppeteer and let nuget pull in the correct ones

It will be the old version of PuppeteerSharp in this case.

Currently I am git clone PuppeteerExtraSharp repo, changed PuppeteerExtraSharp dependency PuppeteerSharp to version 15.1.0, compiled and added it to my project as project reference. Works fine.

warmfire540 commented 8 months ago

Ah I see - you can try and make a PR to update to that version, currently this project using 9.0.2 so a new version may have some issues

Laiteux commented 1 month ago

15.0.0 seems to be the latest to be working, at least with the stealth plugin, as 15.1.0 started throwing that exception.