Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split page #2576

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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