How to Automate Checkbox On Page using Playwright Java
1. Click on method
2. Check method . example page.check("selectors")
3.Un check method example page.uncheck("selectors")
package com.example.pr;
import com.microsoft.playwright.*;
public class CheckBoxesExample {
public static void main(String[] args) throws InterruptedException {
Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false)
.setChannel("chrome")
);
Page page = browser.newPage();
page.navigate("https://qa-practice.netlify.app/checkboxes");
Locator checkbox =page.locator("[type='checkbox']");
for(int i=0;i< checkbox.count();i++){
checkbox.nth(i).click();
}
}
}
Comments
Post a Comment