Search code examples
playwrightplaywright-dotnet

How to click a "type=submit" button in Playright


I tried any possible way to click a "type=submit" button in a form, but it doesn't click the button, the only way is by using "text = ' Register '" but I can't use the text because the form language may change based on the UI language selected by the user.

public Task ClickRegister() => Page.Locator("type=submit").ClickAsync();

Here is the FE code:

<button _ngcontent-yyv-c173="" type="submit" class="btn btn-primary"> Register </button>

I'm using Visual Studio


Solution

  • That's not a valid selector. Can you try something like BUTTON[type="submit"]?