Skip to content

Commit

Permalink
Add response example (#1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Dec 16, 2019
1 parent fded7a4 commit d80f9c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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

0 comments on commit d80f9c6

Please sign in to comment.