Click Radio Button in Playwright Java

Profile picture for user arilio666

To select or assert radio buttons in Playwright, we can use the same methods we used for the checkbox.  It doesn't make sense to uncheck the radio button since it automatically unchecks when you select any other value. 

You will get an error if you try to uncheck the radio buttons.

Select the Radio Button using the Click And Check Method:

        page.navigate("http://autopract.com/selenium/form5/");
        page.locator("input[value='CA']").click();
        page.locator("input[value='mac']").check();
        
  • Here we can select the Canada and mac radio button options.
  • This is how we can use Playwright to select radio buttons effectively.