Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
Hello @Falanga, Rod, DOH ,
I set up a quick local HTML dummy page to run your code, and I have a few suggestions that might solve your issue.
You mentioned you were unsure about the { Name = "Continue" } parameter syntax. Name strictly targets the visible text of the element. The new() { ... } syntax you encountered is simply a standard .NET shorthand for instantiating a PageGetByRoleOptions object.
When reproducing your issue, my test also failed to click. You mentioned a very important detail: "There's a navigation link... users are used to using this button". If front-end developers style an HTML <a> (link) tag with CSS to look like a button, Playwright still strictly maps its semantic role as a Link, not a Button. Changing AriaRole.Button to AriaRole.Link might fix your timeout issue instantly.
Lastly, assigning var h1 = await Expect(...) throws a compiler error because Expect returns void. Expect(...).ToBeVisibleAsync() is the assertion itself, you don't need Assert.Equal. Plus, thanks to Playwright's built-in "Auto-waiting", the Expect method will automatically wait for the heading to render, meaning you can safely delete all the Task.Delay(1000) calls.
It seems your test can be safely shortened to this clean script:
[Fact]
public async Task InputTimeUsingContinue()
{
await Page.GotoAsync("https://FPTimetrack");
// Target the Link role instead of Button
await Page.GetByRole(AriaRole.Link, new() { Name = "Continue" }).ClickAsync();
// Expect is the assertion and it waits automatically, so no Task.Delay is needed
await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Input Time" })).ToBeVisibleAsync();
}
Below are some resources if you want to dive deeper into the specifics:
I hope my testing and research help point you in the right direction. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.