hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.24k stars 431 forks source link

target.asPage in puppeteer c# #2636

Closed bambinorest1 closed 1 month ago

bambinorest1 commented 1 month ago

Is it possible to handle a CDP target of type "other" as a page? In puppeteer js i saw one, but i didn't find in this library. Here url to this method. https://pptr.dev/api/puppeteer.target.aspage

kblok commented 1 month ago

Yes! It works pretty similar

var devtoolsTargetTask = browser.WaitForTargetAsync(t => t.Type == TargetType.Other);
await browser.NewPageAsync();
var devtoolsTarget = await devtoolsTargetTask;
await using var page = await devtoolsTarget.AsPageAsync();