Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vicher opened this issue Apr 2, 2024 · 3 comments

Comments

@Vicher
Copy link

Vicher commented Apr 2, 2024

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
Copy link

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

@Vicher
Copy link
Author

Vicher commented Apr 2, 2024

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants