2023 Trialbee Internship - Cypress
[Internship] Cypress E2E Web Automation | Interacting with Elements | Radio Buttons & Checkboxes
olivia_yj
2023. 4. 13. 00:12
describe("Check UI Elements", () => {
it("Checking Radio Buttons", () => {
cy.visit("https://itera-qa.azurewebsites.net/home/automation");
cy.get("input#male").should("be.visible");
cy.get("input#female").should("be.visible");
});
});
now we are testing "check box"
it("Checking Check Boxes", () => {
cy.visit("https://itera-qa.azurewebsites.net/home/automation");
// visibility of the element
cy.get("input#monday").should("be.visible");
// Selecting single check box - monday
cy.get("input#monday").check().should("be.checked");
// Unselecting checkbox
cy.get("input#monday").uncheck().should("not.be.checked");
});
// Selecting all the check boxes
cy.get("input.form-check-input[type='checkbox']").check.should(
"be.checked"
);
choose tag first and then go into the class (because each item would have the same class) and then go into deeper with '[]' and call the items have type 'checkbox'
Then what about unselecting?
// Selecting all the check boxes
cy.get("input.form-check-input[type='checkbox']").check.should(
"be.checked"
);
// Unselecting all the check boxes
cy.get("input.form-check-input[type='checkbox']").uncheck.should(
"not.be.checked"
);
// Select specific order of item
cy.get("input.form-check-input[type='checkbox']").first().check();
cy.get("input.form-check-input[type='checkbox']").last().check();