Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PuppeteerSharp an alternative to Selenium
#1
Hey guys, 
first I would like to send a thank to Gintaras, for this amazing software
In addition to meeting my needs in terms of automation, LibreAutomate allowed me to discover and start with C#.
I would like to contribute, so I'm sharing this useful alternative to Selenium, which allow an other approach regarding browser automation.

With PuppeteerSharp the browser Chromium is embedded and is by default updated every time you run the code (can be a fix version).
You can chose to launch it with Headless mode enable or disable.
The browser can be easily set to keep the sessions and the coockies, which I find really useful.
You can find more here https://www.puppeteersharp.com/index.html

Just for information, below is a sample code to generate a PDF file from a website page. 
The  "UserDataDir" allow to save the session as with a common browser.




Code:
Copy      Help
/*/ nuget -\PuppeteerSharp; /*/
using System.Windows.Forms;
using PuppeteerSharp;


using var browserFetcher = new BrowserFetcher();
   await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
   var browser = await Puppeteer.LaunchAsync(new LaunchOptions
   {
        Headless = false,
    UserDataDir = @"D:\LibreAutomate - WorkSpaces\LibreAutomate\files\UserData" // Spécifiez le répertoire souhaité pour stocker les données du profil utilisateur
   });


var page = await browser.NewPageAsync();
await page.GoToAsync("https://fr.wikipedia.org/wiki/Mario_Kart:_Super_Circuit");
await page.PdfAsync(@"D:\test\page.pdf");
  // Fermez la page
    await page.CloseAsync();


Hope that can help.


Messages In This Thread
PuppeteerSharp an alternative to Selenium - by Victor-P - 05-21-2023, 06:39 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)