Cypress: lecture 14 - Page Object Model

//Regular lecture 39: 3-Dec-2022
//*Topic*//cypress - lecture 14//Page Object Model//


.js file code:

//page object model (pom)

export class form11{

    visitLoginPage(){
        cy.visit('https://opensource-demo.orangehrmlive.com/web/index.php/auth/login')
    }

    enterUserName(){
        cy.get('[name="username"]').type('Admin')
    }

    enterPassword(){
        cy.get('[type="password"]').type('admin123')
    }

    clickLoginButton(){
        cy.get('[type="submit"]').click()
    }
}

.spec.js file code

/// <reference types ="Cypress"/>

import {form11} from "./script6_pom"

let SauceLogin = new form11()

describe("use_of_pom", function(){

    it("login with valid username & password", function(){
        SauceLogin.visitLoginPage()
        SauceLogin.enterUserName()
        SauceLogin.enterPassword()
        SauceLogin.clickLoginButton()

    })
})

टिप्पण्या