Skip to content

Commit

Permalink
Some progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok committed Dec 20, 2023
1 parent c2f2655 commit c3bd030
Show file tree
Hide file tree
Showing 14 changed files with 492 additions and 286 deletions.
40 changes: 24 additions & 16 deletions demos/PuppeteerSharpPdfDemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,39 @@ class MainClass
{
public static async Task Main(string[] args)
{
var options = new LaunchOptions
Console.WriteLine("Downloading browsers");

using var browserFetcher = new BrowserFetcher(SupportedBrowser.Chrome);
var chrome118 = await browserFetcher.DownloadAsync("118.0.5993.70");
var chrome119 = await browserFetcher.DownloadAsync("119.0.5997.0");

Console.WriteLine("Navigating");
await using (var browser = await Puppeteer.LaunchAsync(new()
{
ExecutablePath = chrome118.GetExecutablePath(),
}))
{
Headless = true
};
await using var page = await browser.NewPageAsync();
await page.GoToAsync("https://www.whatismybrowser.com/");

Console.WriteLine("Downloading chromium");
Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "118.pdf"));

using var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
Console.WriteLine("Export completed");
}

Console.WriteLine("Navigating google");
using (var browser = await Puppeteer.LaunchAsync(options))
using (var page = await browser.NewPageAsync())
await using (var browser = await Puppeteer.LaunchAsync(new()
{
ExecutablePath = chrome119.GetExecutablePath(),
}))
{
await page.GoToAsync("http://www.google.com");
await using var page = await browser.NewPageAsync();
await page.GoToAsync("https://www.whatismybrowser.com/");

Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "119.pdf"));

Console.WriteLine("Export completed");

if (!args.Any(arg => arg == "auto-exit"))
{
Console.ReadLine();
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion demos/PuppeteerSharpPdfDemo/PuppeteerSharpPdfDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PuppeteerSharp" Version="3.0.0" />
<PackageReference Include="PuppeteerSharp" Version="13.0.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ namespace PuppeteerSharp.Tests.EvaluationTests
{
public class FrameEvaluateTests : PuppeteerPageBaseTest
{
public FrameEvaluateTests(): base()
{
}

[PuppeteerTest("evaluation.spec.ts", "Frame.evaluate", "should have different execution contexts")]
[PuppeteerTimeout]
public async Task ShouldHaveDifferentExecutionContexts()
Expand Down
32 changes: 32 additions & 0 deletions lib/PuppeteerSharp.Tests/ScreencastTests/ScreencastTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using PuppeteerSharp.Media;
using PuppeteerSharp.Tests.Attributes;
using PuppeteerSharp.Nunit;
using NUnit.Framework;

namespace PuppeteerSharp.Tests.ScreencastTests
{
public class ScreencastTests : PuppeteerBrowserContextBaseTest
{

[PuppeteerTimeout(-1)]
public async Task Usage()
{using var browserFetcher = new BrowserFetcher();

#region ScreencastUsage
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions());
await using var page = await browser.NewPageAsync();
await page.GoToAsync("https://www.example.com");
var recorder =await page.ScreencastAsync(new ScreencastOptions
{
Path = "recording.webm",
});

await recorder.StopAsync();
#endregion
}
}
}
Loading

0 comments on commit c3bd030

Please sign in to comment.