Playwright .NET and Blazor

Viewed 15

I'm using Blazor with .NET 5 and I have a form which has an input number like this:

 <InputNumber id="age" @bind-Value="@myObject.Age" />

I'm trying to use Playwright to test boundary conditions for the error message on this form input by using:

[Theory]
    [InlineData(-1)]
    [InlineData(0)]
    [InlineData(1001)]
    public async void CreatePerson_InvalidAge(int age)
    {
        using var playwright = await Playwright.CreateAsync();
        await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true, SlowMo = 500 });
        await using var context = await browser.NewContextAsync();

    var page = await context.NewPageAsync();

    await page.GotoAsync(baseUrl);

    await page.Locator("id=age").FillAsync(age);
    await page.Locator("id=saveBtn").ClickAsync();

    var errorMessage = await page.Locator("id=ageErrMsg").First.InnerTextAsync();

    Assert.Equal("Age must be between 1 - 200", errorMessage);
}

Except .FillAsync is giving me an error with "cannot convert int to string". How do I put a number into my InputNumber form control?

0 Answers
Related