Skip to content

Instantly share code, notes, and snippets.

@Chandankkrr
Last active July 25, 2021 07:09
Show Gist options
  • Save Chandankkrr/8bc589ed523e093341c33a91c459504e to your computer and use it in GitHub Desktop.
Save Chandankkrr/8bc589ed523e093341c33a91c459504e to your computer and use it in GitHub Desktop.
Playwright Network Monitoring
using System;
using System.Threading.Tasks;
using Microsoft.Playwright;
namespace ConsoleApp
{
class Program
{
static async Task Main(string[] args)
{
const string email = "test.user@blazor.com";
const string password = "Test1234#";
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
page.Request += (_, request) =>
Console.WriteLine($">> {request.Method}, {request.Url}");
page.Response += (_, response) =>
Console.WriteLine($">> {response.Status}, {response.Url}");
await page.GotoAsync("https://victorious-tree-06261d500.azurestaticapps.net/register");
// Fill input[type="text"]
await page.FillAsync("input[type=\"text\"]", email);
// Fill input[type="password"]
await page.FillAsync("input[type=\"password\"]", password);
// Fill text=PasswordRepeat the password >> input[type="password"]
await page.FillAsync("text=PasswordRepeat the password >> input[type=\"password\"]", password);
// Click button:has-text("Register")
await page.ClickAsync("button:has-text(\"Register\")");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment