Skip to content

Commit c43ee44

Browse files
kblokactions-user
andauthored
Split page (#2576)
* Split page * Docs changes --------- Co-authored-by: GitHub Action <[email protected]>
1 parent ff23f14 commit c43ee44

File tree

8 files changed

+1690
-1314
lines changed

8 files changed

+1690
-1314
lines changed

lib/PuppeteerSharp/Cdp/CdpPage.cs

Lines changed: 1290 additions & 0 deletions
Large diffs are not rendered by default.

lib/PuppeteerSharp/Cdp/CdpPageTarget.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public override async Task<IPage> PageAsync()
3737
{
3838
if (PageTask == null)
3939
{
40-
var session = Session ?? await SessionFactory(false).ConfigureAwait(false);
40+
var session = (CdpCDPSession)(Session ?? await SessionFactory(false).ConfigureAwait(false));
4141

42-
PageTask = Page.CreateAsync(
42+
PageTask = CdpPage.CreateAsync(
4343
session,
4444
this,
4545
_ignoreHTTPSErrors,

lib/PuppeteerSharp/Cdp/CdpTarget.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public override async Task<IPage> AsPageAsync()
5454
{
5555
if (Session == null)
5656
{
57-
var session = await CreateCDPSessionAsync().ConfigureAwait(false) as CDPSession;
58-
return await Page.CreateAsync(session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
57+
var session = (CdpCDPSession)await CreateCDPSessionAsync().ConfigureAwait(false);
58+
return await CdpPage.CreateAsync(session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
5959
}
6060

61-
return await Page.CreateAsync(Session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
61+
return await CdpPage.CreateAsync((CdpCDPSession)Session, this, false, null, ScreenshotTaskQueue).ConfigureAwait(false);
6262
}
6363

6464
/// <inheritdoc/>

lib/PuppeteerSharp/Frame.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,19 @@ public async Task FocusAsync(string selector)
275275
await handle.FocusAsync().ConfigureAwait(false);
276276
}
277277

278+
/// <inheritdoc/>
279+
public async Task TapAsync(string selector)
280+
{
281+
var handle = await QuerySelectorAsync(selector).ConfigureAwait(false);
282+
if (handle == null)
283+
{
284+
throw new SelectorException($"No node found for selector: {selector}", selector);
285+
}
286+
287+
await handle.TapAsync().ConfigureAwait(false);
288+
await handle.DisposeAsync().ConfigureAwait(false);
289+
}
290+
278291
/// <inheritdoc/>
279292
public async Task TypeAsync(string selector, string text, TypeOptions options = null)
280293
{

lib/PuppeteerSharp/IFrame.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,5 +451,13 @@ public interface IFrame
451451
/// <param name="options">Optional waiting parameters.</param>
452452
/// <returns>A task that resolves after the page gets the prompt.</returns>
453453
Task<DeviceRequestPrompt> WaitForDevicePromptAsync(WaitForOptions options = null);
454+
455+
/// <summary>
456+
/// 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.
457+
/// </summary>
458+
/// <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>
459+
/// <exception cref="SelectorException">If there's no element matching <paramref name="selector"/>.</exception>
460+
/// <returns>Task which resolves when the element matching <paramref name="selector"/> is successfully tapped.</returns>
461+
Task TapAsync(string selector);
454462
}
455463
}

lib/PuppeteerSharp/IResponse.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace PuppeteerSharp
99
/// <summary>
1010
/// <see cref="IResponse"/> class represents responses which are received by page.
1111
/// </summary>
12-
/// <seealso cref="Page.GoAsync(int, NavigationOptions)"/>
1312
/// <seealso cref="IPage.GoForwardAsync(NavigationOptions)"/>
1413
/// <seealso cref="IPage.ReloadAsync(int?, WaitUntilNavigation[])"/>
1514
/// <seealso cref="IPage.Response"/>

0 commit comments

Comments
 (0)