Last active
May 17, 2020 15:39
-
-
Save sujaykundu777/2af6424c8a253bd461a4b8024fbd6913 to your computer and use it in GitHub Desktop.
cypress sample test cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example test case | |
describe("Test Case Name", () => { | |
// Test case goes here | |
it("test case name", () => { | |
// cypress commands goes here | |
cy.visit("/"); | |
}); | |
}); | |
// describe block | |
describe("Test case aNAme", () => { | |
// test cases (it) goes here | |
}); | |
// it block | |
it("test case name", () => { | |
// cypress (cy) commands goes here | |
}); | |
// Below are the cypress commands you can use by copy pasting in to your test cases as required | |
// Visit the website/url | |
cy.visit("/"); | |
// select a element (heading) | |
cy.get('h1'); // h1 | |
cy.get('h2'); // h2 | |
cy.get('h3'); // h3 | |
cy.get('h4'); // h4 | |
cy.get('h5'); // h5 | |
cy.get('h6'); // h6 | |
// Select a DOM (input) element | |
cy.get('input[name="name"]') // using name | |
cy.get('input[class="class1"]') // using class | |
cy.get('input[id="id1"]') // using id | |
cy.get('input[type="email"]') // using type | |
// type text after selecting a input | |
cy.get('input[name="name"]').type("Enter text here") | |
cy.get('input[class="class1"]') .type("Enter text here") | |
cy.get('input[id="id1"]').type("Enter text here") | |
cy.get('input[type="email"]').type("Enter text here") | |
// selecting a button and clicking | |
cy.get('button').click() | |
// submit form | |
cy.get('form').submit() | |
// find a nested element | |
// <ul> | |
// <li id="1"> firstone | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment