Skip to content

Commit d80f9c6

Browse files
authored
Add response example (#1350)
1 parent fded7a4 commit d80f9c6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/PuppeteerSharp/Page.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,26 @@ private Page(
165165
/// <summary>
166166
/// Raised when a <see cref="Response"/> is received.
167167
/// </summary>
168+
/// <example>
169+
/// An example of handling <see cref="Response"/> event:
170+
/// <code>
171+
/// <![CDATA[
172+
/// var tcs = new TaskCompletionSource<string>();
173+
/// page.Response += async(sender, e) =>
174+
/// {
175+
/// if (e.Response.Url.Contains("script.js"))
176+
/// {
177+
/// tcs.TrySetResult(await e.Response.TextAsync());
178+
/// }
179+
/// };
180+
///
181+
/// await Task.WhenAll(
182+
/// page.GoToAsync(TestConstants.ServerUrl + "/grid.html"),
183+
/// tcs.Task);
184+
/// Console.WriteLine(await tcs.Task);
185+
/// ]]>
186+
/// </code>
187+
/// </example>
168188
public event EventHandler<ResponseCreatedEventArgs> Response;
169189

170190
/// <summary>

lib/PuppeteerSharp/Response.cs

100755100644
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ namespace PuppeteerSharp
1212
/// <summary>
1313
/// <see cref="Response"/> class represents responses which are received by page.
1414
/// </summary>
15+
/// <seealso cref="Page.GoAsync(int, NavigationOptions)"/>
16+
/// <seealso cref="Page.GoForwardAsync(NavigationOptions)"/>
17+
/// <seealso cref="Page.ReloadAsync(int?, WaitUntilNavigation[])"/>
18+
/// <seealso cref="Page.Response"/>
19+
/// <seealso cref="Page.WaitForResponseAsync(Func{Response, bool}, WaitForOptions)"/>
1520
public class Response
1621
{
1722
private readonly CDPSession _client;

0 commit comments

Comments
 (0)