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

Add response example #1350

Merged
merged 1 commit into from
Dec 16, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/PuppeteerSharp/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ private Page(
/// <summary>
/// Raised when a <see cref="Response"/> is received.
/// </summary>
/// <example>
/// An example of handling <see cref="Response"/> event:
/// <code>
/// <![CDATA[
/// var tcs = new TaskCompletionSource<string>();
/// page.Response += async(sender, e) =>
/// {
/// if (e.Response.Url.Contains("script.js"))
/// {
/// tcs.TrySetResult(await e.Response.TextAsync());
/// }
/// };
///
/// await Task.WhenAll(
/// page.GoToAsync(TestConstants.ServerUrl + "/grid.html"),
/// tcs.Task);
/// Console.WriteLine(await tcs.Task);
/// ]]>
/// </code>
/// </example>
public event EventHandler<ResponseCreatedEventArgs> Response;

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions lib/PuppeteerSharp/Response.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace PuppeteerSharp
/// <summary>
/// <see cref="Response"/> class represents responses which are received by page.
/// </summary>
/// <seealso cref="Page.GoAsync(int, NavigationOptions)"/>
/// <seealso cref="Page.GoForwardAsync(NavigationOptions)"/>
/// <seealso cref="Page.ReloadAsync(int?, WaitUntilNavigation[])"/>
/// <seealso cref="Page.Response"/>
/// <seealso cref="Page.WaitForResponseAsync(Func{Response, bool}, WaitForOptions)"/>
public class Response
{
private readonly CDPSession _client;
Expand Down