Skip to content

Commit

Permalink
Upgrade to PuppeteerSharp 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland committed Jul 12, 2024
1 parent 503a931 commit 5b900ff
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions PuppeteerSharp.Dom.Tests/ClickTests/ClickTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public async Task ShouldSelectTheTextByTripleClicking()

await Page.Keyboard.TypeAsync(expected);
await Page.ClickAsync("textarea");
await Page.ClickAsync("textarea", new ClickOptions { ClickCount = 2 });
await Page.ClickAsync("textarea", new ClickOptions { ClickCount = 3 });
await Page.ClickAsync("textarea", new ClickOptions { Count = 2 });
await Page.ClickAsync("textarea", new ClickOptions { Count = 3 });

var actual = await Page.EvaluateFunctionAsync<string>(@"() => {
const textarea = document.querySelector('textarea');
Expand Down Expand Up @@ -187,7 +187,7 @@ await Page.EvaluateExpressionAsync(@"{
});
}");
var button = await Page.QuerySelectorAsync<HtmlButtonElement>("button");
await button.ClickAsync(new ClickOptions { ClickCount = 2 });
await button.ClickAsync(new ClickOptions { Count = 2 });
Assert.True(await Page.EvaluateExpressionAsync<bool>("double"));
Assert.Equal("Clicked", await Page.EvaluateExpressionAsync<string>("result"));
}
Expand Down
7 changes: 5 additions & 2 deletions PuppeteerSharp.Dom.Tests/FrameUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ await page.EvaluateFunctionAsync(@"function detachFrame(frameId) {
public static IEnumerable<string> DumpFrames(IFrame frame, string indentation = "")
{
var description = indentation + Regex.Replace(frame.Url, @":\d{4}", ":<PORT>");
if (!string.IsNullOrEmpty(frame.Name))
#pragma warning disable CS0618 // Type or member is obsolete
var name = frame.Name;
#pragma warning restore CS0618 // Type or member is obsolete
if (!string.IsNullOrEmpty(name))
{
description += $" ({frame.Name})";
description += $" ({name})";
}
var result = new List<string>() { description };
foreach (var child in frame.ChildFrames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public PuppeteerBrowserContextBaseTest(ITestOutputHelper output) : base(output)
public override async Task InitializeAsync()
{
await base.InitializeAsync();
Context = await Browser.CreateIncognitoBrowserContextAsync();
Context = await Browser.CreateBrowserContextAsync();
}
}
}
2 changes: 1 addition & 1 deletion PuppeteerSharp.Dom.Tests/PuppeteerLoaderFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Dispose()

private async Task SetupAsync()
{
using var browserFetcher = new BrowserFetcher(SupportedBrowser.Chrome);
var browserFetcher = new BrowserFetcher(SupportedBrowser.Chrome);
var downloaderTask = browserFetcher.DownloadAsync();

Server = SimpleServer.Create(TestConstants.Port, TestUtils.FindParentDirectory("PuppeteerSharp.Dom.TestServer"));
Expand Down
2 changes: 1 addition & 1 deletion PuppeteerSharp.Dom.Tests/PuppeteerSharp.Dom.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="MarkdownSnippets.MsBuild" Version="24.5.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="PuppeteerSharp" Version="14.0.0" />
<PackageReference Include="PuppeteerSharp" Version="18.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static async Task Usage()
{
#region QuerySelector

using var browserFetcher = new BrowserFetcher();
var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
await using var page = await browser.NewPageAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task Usage()
{
#region QuerySelectorAll

using var browserFetcher = new BrowserFetcher();
var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
await using var page = await browser.NewPageAsync();
Expand Down
2 changes: 1 addition & 1 deletion PuppeteerSharp.Dom/DomHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using PuppeteerSharp.Messaging;
using PuppeteerSharp.Cdp.Messaging;

namespace PuppeteerSharp.Dom
{
Expand Down
4 changes: 2 additions & 2 deletions PuppeteerSharp.Dom/HtmlElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Task PressAsync(string key, PressOptions options = null)
}

/// <summary>
/// Scrolls element into view if needed, and then uses <see cref="Page.Mouse"/> to hover over the center of the element.
/// Scrolls element into view if needed, and then uses <see cref="IPage.Mouse"/> to hover over the center of the element.
/// </summary>
/// <returns>Task which resolves when the element is successfully hovered</returns>
public Task HoverAsync()
Expand All @@ -118,7 +118,7 @@ public Task HoverAsync()
}

/// <summary>
/// Scrolls element into view if needed, and then uses <see cref="Page.Mouse"/> to click in the center of the element.
/// Scrolls element into view if needed, and then uses <see cref="IPage.Mouse"/> to click in the center of the element.
/// </summary>
/// <param name="options">click options</param>
/// <exception cref="PuppeteerException">if the element is detached from DOM</exception>
Expand Down
9 changes: 5 additions & 4 deletions PuppeteerSharp.Dom/PageExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using PuppeteerSharp.Cdp.Messaging;

namespace PuppeteerSharp.Dom
{
Expand All @@ -26,10 +27,10 @@ public static T ToDomHandle<T>(this IJSHandle jsHandle)
var remoteObject = jsHandle.RemoteObject;

// Types like FileList are of SubType other
if (remoteObject.Type == Messaging.RemoteObjectType.Object &&
(remoteObject.Subtype == Messaging.RemoteObjectSubtype.Node ||
remoteObject.Subtype == Messaging.RemoteObjectSubtype.Array ||
remoteObject.Subtype == Messaging.RemoteObjectSubtype.Other))
if (remoteObject.Type == RemoteObjectType.Object &&
(remoteObject.Subtype == RemoteObjectSubtype.Node ||
remoteObject.Subtype == RemoteObjectSubtype.Array ||
remoteObject.Subtype == RemoteObjectSubtype.Other))
{
return HtmlObjectFactory.CreateObject<T>(remoteObject.ClassName, jsHandle);
}
Expand Down
2 changes: 0 additions & 2 deletions PuppeteerSharp.Dom/PuppeteerSharp.Dom.CodeGen.Partial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using PuppeteerSharp.Messaging;

namespace PuppeteerSharp.Dom
{
Expand Down
4 changes: 2 additions & 2 deletions PuppeteerSharp.Dom/PuppeteerSharp.Dom.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>PuppeteerSharp.Dom</PackageId>
<PackageReleaseNotes>Upgrade to PuppeteerSharp to 14.0</PackageReleaseNotes>
<PackageReleaseNotes>Upgrade to PuppeteerSharp 18.0</PackageReleaseNotes>
<VersionPrefix>4.0.0</VersionPrefix>
<!--<VersionSuffix>preview01</VersionSuffix>-->
<DebugType>embedded</DebugType>
Expand All @@ -37,7 +37,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PuppeteerSharp" Version="14.0.0" />
<PackageReference Include="PuppeteerSharp" Version="18.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Read/write to the DOM
<!-- snippet: QuerySelector -->
<a id='snippet-queryselector'></a>
```cs
using var browserFetcher = new BrowserFetcher();
var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
await using var page = await browser.NewPageAsync();
Expand Down

0 comments on commit 5b900ff

Please sign in to comment.