Skip to content

Commit

Permalink
feat(page): introduce Page.PauseAsync (microsoft#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Feb 22, 2021
1 parent eeabde4 commit d87d75c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/PlaywrightSharp/BrowserContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ public async Task<StorageState> GetStorageStateAsync(string path = null)
return state;
}

internal Task PauseAsync() => Channel.PauseAsync();

internal void OnRoute(Route route, Request request)
{
foreach (var item in _routes)
Expand Down
13 changes: 12 additions & 1 deletion src/PlaywrightSharp/IPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
using System.IO;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using PlaywrightSharp.Input;

Expand Down Expand Up @@ -1803,5 +1802,17 @@ Task<byte[]> GetPdfAsync(
/// The default value can be changed by using the <see cref="IBrowserContext.DefaultTimeout"/> or <see cref="IPage.DefaultTimeout"/>.</param>
/// <returns>A <see cref="Task"/> that completes when the message is processed by the browser.</returns>
Task<bool> IsVisibleAsync(string selector, int? timeout = null);

/// <summary>
/// Pauses script execution. Playwright will stop executing the script and wait for the user to either press 'Resume' button
/// in the page overlay or to call `playwright.resume()` in the DevTools console.
///
/// User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
/// the place it was paused.
///
/// > NOTE: This method requires Playwright to be started in a headed mode, with a falsy `headless` value in the <seealso cref="IBrowserType.LaunchAsync(bool?, string[], string, bool?, string, string, bool?, int?, bool?, int?, bool?, string[], Dictionary{string, string}, Dictionary{string, object}, ProxySettings, bool?, bool?, bool?, bool?)"/>.
/// </summary>
/// <returns>A <see cref="Task"/> that completes when the message is processed by the browser.</returns>
Task PauseAsync();
}
}
3 changes: 3 additions & 0 deletions src/PlaywrightSharp/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ public Task TapAsync(string selector, Modifier[] modifiers = null, Point? positi
/// <inheritdoc />
public Task<bool> IsVisibleAsync(string selector, int? timeout = null) => MainFrame.IsVisibleAsync(true, selector, timeout);

/// <inheritdoc />
public Task PauseAsync() => Context.PauseAsync();

internal void OnFrameNavigated(Frame frame)
=> FrameNavigated?.Invoke(this, new FrameEventArgs(frame));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,8 @@ internal Task<CDPSessionChannel> NewCDPSessionAsync(IPage page)

internal Task<StorageState> GetStorageStateAsync()
=> Connection.SendMessageToServerAsync<StorageState>(Guid, "storageState", null);

internal Task PauseAsync()
=> Connection.SendMessageToServerAsync(Guid, "pause", null);
}
}

0 comments on commit d87d75c

Please sign in to comment.