microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.45k stars 232 forks source link

[Bug]: AddInitScriptAsync strange behavior #2998

Closed drRobertDev closed 1 week ago

drRobertDev commented 1 week ago

Version

1.46

Steps to reproduce

    //PuppeteerSharp       
    var _puppeter = await Puppeteer.LaunchAsync(new LaunchOptions() {
        Headless = false,
        Args = ["--disable-blink-features=AutomationControlled"]
    });
    var pagea = await _puppeter.NewPageAsync();

    await pagea.EvaluateExpressionOnNewDocumentAsync("console.log('Hello from the browser!')"); //not trigger CloudFlare on click links

    await pagea.GoToAsync("https://www.futbin.com/players");

    //Playwright
    var _playwright = await Playwright.CreateAsync();
    var chrom = await _playwright.Chromium.LaunchAsync(new() { 
        Headless = false,
        Args = ["--disable-blink-features=AutomationControlled"]
    });
    var pageb = await chrom.NewPageAsync(null);

    await pageb.AddInitScriptAsync("console.log('Hello from the browser!')"); //trigger CloudFlare on click links

    await pageb.GotoAsync("https://www.futbin.com/players");

Expected behavior

You can load target web Page with PuppeteerSharp and Playwright this is good, but when you click links inside page if you use AddInitScriptAsync it will trigger CloudFlare (without AddInit not trigger it), i made same test on PuppeteerSharp cause it will call same function on Node (Page.addScriptToEvaluateOnNewDocument) it work. Then should be something wrong in implementation with AddInitScriptAsync

Actual behavior

When you use AddInitScriptAsync and click links on target page will trigger CloudFlare, without not trigger it.

Additional context

No response

Environment

- Operating System: [Windows]
- CPU: [x64]
- Browser: [Chromium,]
- .NET Version (TFM): [net8.0]
mxschmitt commented 1 week ago

This seems outside of the scope for Playwright - we are an automation library and not a library which aims to overcome Cloudflare.