Skip to content

Releases: hardkoded/puppeteer-sharp

v19.0.1

20 Aug 18:34
bdd47e2
Compare
Choose a tag to compare

What's Changed

Full Changelog: v19.0.0...v19.0.1

v19.0.0

20 Aug 12:34
9aa23f3
Compare
Choose a tag to compare

Welcome System.Text.Json and AOT support!

What's new

Full AOT Support.

v19 comes with one of the most significant changes made to this library. We are moving away from Newtonsoft JSON in favor of System.Text.Json. The motivation behind this change is that it would get us closer to AOT support.

If you are using your own classes to interact with the browser through EvaluateFunctionAsync or similar, you will have to provide your own JsonSerializerContext to puppeteer using the static Puppeteer.ExtraJsonSerializerContext property.

For instance.

Puppeteer.ExtraJsonSerializerContext = DemoJsonSerializationContext.Default;
await using var browser = await Puppeteer.LaunchAsync();
await using var page = await browser.NewPageAsync();
var result = await page.EvaluateFunctionAsync<TestClass>("test => test", new TestClass { Name = "Dario"});
Console.WriteLine($"Name evaluated to {result.Name}");

The serializer would look like this:

public class TestClass
{
    public string Name { get; set; }
}

[JsonSerializable(typeof(TestClass))]
public partial class DemoJsonSerializationContext : JsonSerializerContext
{}

For more information about JsonSerializerContext see How to use source generation in System.Text.Json.

Breaking changes

JSON is critical for PuppeteerSharp. It's how we communicate with the browser, so changing the library used to perform this communication is quite risky.
Newtonsoft JSON classes were also used in our API, so your code might have some breaking changes.

Newtonsoft's JToken was replaced with JsonElement

JToken was the default type for functions like EvaluationFunctionAsync, EvaluateExpressionAsync or JsonAsync, when the generic function was not used.

Before:

var objectPopulated = await Page.EvaluateExpressionAsync("var obj = {a:1}; obj;");
Assert.AreEqual(1, objectPopulated["a"]);

Now:

var objectPopulated = await Page.EvaluateExpressionAsync("var obj = {a:1}; obj;");
Assert.AreEqual(1, objectPopulated.Value.GetProperty("a").GetInt32());

Use JsonElement instead of object

I found that it's easy to consume JsonElement instead of objects that are really JsonElements.

Before

var result = await Page.EvaluateExpressionAsync<object[]>("result");
Assert.AreEqual("Meta", result[0]);
Assert.AreEqual("MetaLeft", result[1]);
Assert.AreEqual(true, result[2]);

After

var result = await Page.EvaluateExpressionAsync<JsonElement[]>("result");
Assert.AreEqual("Meta", result[0].GetString());
Assert.AreEqual("MetaLeft", result[1].GetString());
Assert.AreEqual(true, result[2].GetBoolean());

Aria selector changes

Previously, Puppeteer incorrectly normalized whitespaces in ARIA selectors in a way that did not not allow distinguishing between the following two HTML structures:

<p>  text<p>
<p><span>&nbsp;</span><span>&nbsp;</span>text<p>

In the first case, the spaces are not part of the element's textual content, and the element should be found via aria/text.

In the second case, the spaces are part of the p element and the query aria/\u00A0\u00A0text should find it while aria/text should not. The whitespace normalization in Puppeteer would previously prevent searching for the element with whitespaces in the textual content.

Related: the step 2.F of https://www.w3.org/TR/accname-1.2/#computation-steps defines how child elements contribute to the parent element's computed name.

If you need the old behavior, apply selector.replace(/ +/g, ' ').trim() to your ARIA selector.

IgnoreHTTPErrors was renamed to AcceptInsecureCerts

This change will get us closer to WebDriver Bidi Support.

v18.1.0

08 Aug 12:24
2d44dc7
Compare
Choose a tag to compare

What's Changed

Full Changelog: v18.0.5...v18.1.0

v18.0.5

22 Jul 22:21
f5ebfa6
Compare
Choose a tag to compare

What's Changed

Full Changelog: v18.0.4...v18.0.5

v18.0.4

15 Jul 21:43
85aa4b0
Compare
Choose a tag to compare

What's Changed

  • Update sponsors by @github-actions in #2690
  • Ensure temp directory is deleted on disposal by @kblok in #2689

Full Changelog: v18.0.3...v18.0.4

v18.0.3

03 Jul 18:53
eca1640
Compare
Choose a tag to compare

Important

  • Chrome 125 proved to be problematic for windows users. We are rolling back to Chrome 124.

What's Changed

  • fix Page.RemoveExposedFunctionAsync by @ravriel in #2671
  • Gracefully tear down test if SetUp failed by @jnyrup in #2672
  • Fix: BrowserContext.IsClosed returns true when a context is not closed by @IliaBrahinets in #2668
  • Ensure existing targets are attached to pages by @kblok in #2670

New Contributors

Full Changelog: v18.0.2...v18.0.3

v18.0.2

24 Jun 11:54
88dc82c
Compare
Choose a tag to compare

What's Changed

  • Update sponsors by @github-actions in #2647
  • Switch to Firefox stable version by @kblok in #2662
  • Replace WebException with HttpRequestException by @kblok in #2655
  • Bump patch version to 18.0.2 by @kblok in #2665

Full Changelog: v18.0.1...v18.0.2

v18.0.1

06 Jun 11:27
42b1fd0
Compare
Choose a tag to compare

What's Changed

Full Changelog: v18.0.0...v18.0.1

v18.0.0

20 May 19:36
5d6c91c
Compare
Choose a tag to compare

Breaking Change

What's new

What's Changed

Full Changelog: v17.0.0...v18.0.0

v17.0.0

23 Apr 13:53
Compare
Choose a tag to compare

Breaking change

Hopefully these features are not that popular

What's new

  • Chrome 124
  • Introduce Page.SetBypassServiceWorkerAsync by @kblok in #2587
  • Introduce Frame.FrameElement by @kblok in #2602

What's Changed

  • Revert "Introduce protocol in launch options (#2578)" by @kblok in #2585
  • Make isIntersectingViewport work with SVG elements by @kblok in #2586
  • Make page.goBack work with bfcache in tab mode by @kblok in #2589
  • Ensure fission.bfcacheInParent is disabled for cdp in Firefox by @kblok in #2591
  • Update cookies object model by @kblok in #2592
  • [BREAKING]: Remove WaitForTimeoutAsync by @kblok in #2595
  • [BREAKING] Rename ClickCount to Count by @kblok in #2600
  • Remove NetworkServiceInProcess2 set by default by @kblok in #2601
  • [BREAKING] Deprecate Frame.Name and expose FrameElement by @kblok in #2602
  • Reduce memory allocations and use collection expressions in JSHandle by @IliaBrahinets in #2604
  • Reload should not resolve early on fragment navigations by @kblok in #2603
  • Query only unignored nodes by @kblok in #2606

New Contributors

Full Changelog: v16.0.0...v17.0.0