2023 Trialbee Internship - Cypress 15

[Internship] Cypress E2E Web Automation | Hooks & Tags

Before executes one time before the whole code, and for after it's vice versa BeforeEach and AfterEach executes every before and after. // before // after // beforeEach // AfterEach describe("MyTestSuite", () => { before(() => { cy.log("***** Launch app *****"); }); after(() => { cy.log("***** close app *****"); }); beforeEach(() => { cy.log("****** Login *******"); }); afterEach(() => { cy.log(..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Handling File Upload

import "cypress-file-upload"; describe("File Uploads", () => { it.skip("Single File Upload", () => { cy.visit("http://the-internet.herokuapp.com/upload"); cy.get("#file-upload").attachFile("test1.pdf"); cy.get("#file-submit").click(); cy.wait(5000); cy.get("div[class='example'] h3").should("have.text", "File Uploaded!"); }); it.skip("File Upload - Rename", () => { cy.visit("http://the-internet.h..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Handling Mouse Events

import "cypress-iframe"; require("@4w/cypress-drag-drop"); describe("Mouse Operations", () => { it.skip("MouseHover", () => { cy.visit("https://demo.opencart.com/"); cy.get( "body > main:nth-child(3) > div:nth-child(1) > nav:nth-child(1) > div:nth-child(3)>ul:nth-child(1)>li:nth-child(2)>a:nth-child(1)" ).should("not.be.visible"); cy.get(".nav > :nth-child(1) > .dropdown-toggle") .trigger("mouse..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Handling Tables

wrap Yield the object passed into .wrap(). If the object is a promise, yield its resolved value. Syntax​ cy.wrap(subject) cy.wrap(subject, options) Usage​ Correct Usage cy.wrap({ name: 'Jane Lane' }) Arguments​ subject (Object) An object to be yielded. options (Object) Pass in an options object to change the default behavior of cy.wrap(). OptionDefaultDescription Yields ​ cy.wrap() yields the ob..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Handling iFrames

import "cypress-iframe"; describe("handling frames", () => { it.skip("approach1", () => { cy.visit("https://the-internet.herokuapp.com/iframe"); const iframe = cy .get("#mce_0_ifr") .its("0.contentDocument.body") .should("be.visible") .then(cy.wrap); iframe.clear().type("Welcome {cmd+a}"); // {cmd+a}: because we need to change all the words to bold cy.get("[aria-label='Bold']").click(); }); // w..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Handling Child Tabs

describe("Handle tab-approach1", () => { it("Approach1", () => { cy.visit("https://the-internet.herokuapp.com/windows"); // parent tab; cy.get(".example > a").invoke("removeAttr", "target").click(); // clicking link; cy.url().should( "include", "https://the-internet.herokuapp.com/windows/new" ); cy.wait(5000); // operations cy.go("back"); // back to parent tab }); }); it("Approach2", () => { cy...

[Internship] Cypress E2E Web Automation | Interacting with Elements | Alerts

1. Javascript Alert: It will have some text and an 'OK' button 2. Javascript Confirm Alert: It will have some text with 'OK' and 'Cancel' buttons 3. Javascript Prompt Alert: It will have some text with a text box for user input along with 'OK' 4. Authenticated Alert Stub A stub is a way to modify a function and delegate control over its behavior to you (the programmer). A stub is most commonly u..

[Internship] Cypress E2E Web Automation | Interacting with Elements | DropDowns

describe("handle dropdowns", () => { it("Dropdown with select", () => { cy.visit("https://www.zoho.com/commerce/free-demo.html"); cy.get("#zcf_address_country") .select("Italy") .should("have.value", "Italy"); }); }); it.skip("Dropdown without select", () => { cy.visit("https://www.dummyticket.com/dummy-ticket-for-visa-application/"); cy.get("#select2-billing_country-container").click(); cy.get(..

[Internship] Cypress E2E Web Automation | Interacting with Elements | Radio Buttons & Checkboxes

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.g..

[Internship] Cypress E2E Web Automation |Folder Structure | IntelliSense Auto Suggestions

We can also use support/commands.js folder to use already annotated commands command.js // *********************************************** // This example commands.js shows you how to // create various custom commands and overwrite // existing commands. // // For more comprehensive examples of custom // commands please read more here: // https://on.cypress.io/custom-commands // *****************..