Skip to content

Commit

Permalink
Split page (#2576)
Browse files Browse the repository at this point in the history
* Split page

* Docs changes

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
kblok and actions-user committed Mar 30, 2024
1 parent ff23f14 commit c43ee44
Show file tree
Hide file tree
Showing 8 changed files with 1,690 additions and 1,314 deletions.
1,290 changes: 1,290 additions & 0 deletions lib/PuppeteerSharp/Cdp/CdpPage.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/PuppeteerSharp/Cdp/CdpPageTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public override async Task<IPage> PageAsync()
{
if (PageTask == null)
{
var session = Session ?? await SessionFactory(false).ConfigureAwait(false);
var session = (CdpCDPSession)(Session ?? await SessionFactory(false).ConfigureAwait(false));

PageTask = Page.CreateAsync(
PageTask = CdpPage.CreateAsync(
session,
this,
_ignoreHTTPSErrors,
Expand Down
6 changes: 3 additions & 3 deletions lib/PuppeteerSharp/Cdp/CdpTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public override async Task<IPage> AsPageAsync()
{
if (Session == null)
{
var session = await CreateCDPSessionAsync().ConfigureAwait(false) as CDPSession;
return await Page.CreateAsync(session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
var session = (CdpCDPSession)await CreateCDPSessionAsync().ConfigureAwait(false);
return await CdpPage.CreateAsync(session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
}

return await Page.CreateAsync(Session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
return await CdpPage.CreateAsync((CdpCDPSession)Session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
}

/// <inheritdoc/>
Expand Down
13 changes: 13 additions & 0 deletions lib/PuppeteerSharp/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,19 @@ public async Task FocusAsync(string selector)
await handle.FocusAsync().ConfigureAwait(false);
}

/// <inheritdoc/>
public async Task TapAsync(string selector)
{
var handle = await QuerySelectorAsync(selector).ConfigureAwait(false);
if (handle == null)
{
throw new SelectorException($"No node found for selector: {selector}", selector);
}

await handle.TapAsync().ConfigureAwait(false);
await handle.DisposeAsync().ConfigureAwait(false);
}

/// <inheritdoc/>
public async Task TypeAsync(string selector, string text, TypeOptions options = null)
{
Expand Down
8 changes: 8 additions & 0 deletions lib/PuppeteerSharp/IFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,13 @@ public interface IFrame
/// <param name="options">Optional waiting parameters.</param>
/// <returns>A task that resolves after the page gets the prompt.</returns>
Task<DeviceRequestPrompt> WaitForDevicePromptAsync(WaitForOptions options = null);

/// <summary>
/// Fetches an element with <paramref name="selector"/>, scrolls it into view if needed, and then uses <see cref="Touchscreen"/> to tap in the center of the element.
/// </summary>
/// <param name="selector">A selector to search for element to tap. If there are multiple elements satisfying the selector, the first will be clicked.</param>
/// <exception cref="SelectorException">If there's no element matching <paramref name="selector"/>.</exception>
/// <returns>Task which resolves when the element matching <paramref name="selector"/> is successfully tapped.</returns>
Task TapAsync(string selector);
}
}
1 change: 0 additions & 1 deletion lib/PuppeteerSharp/IResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace PuppeteerSharp
/// <summary>
/// <see cref="IResponse"/> class represents responses which are received by page.
/// </summary>
/// <seealso cref="Page.GoAsync(int, NavigationOptions)"/>
/// <seealso cref="IPage.GoForwardAsync(NavigationOptions)"/>
/// <seealso cref="IPage.ReloadAsync(int?, WaitUntilNavigation[])"/>
/// <seealso cref="IPage.Response"/>
Expand Down

0 comments on commit c43ee44

Please sign in to comment.