My page object file is like below
///
const LOGIN_PAGE_HEADER_TEXT = '.welcome-message > h1';
class LoginPage {
get loginPageHeaderText() {
return cy.get(LOGIN_PAGE_HEADER_TEXT, {timeout: 140000});
}
}
export default LoginPage;
I want to use a custom command to check the Page header text and the text is dynamic
So I tried to write a custom command like below
Cypress.Commands.add('shouldContain', (element , text) => {
cy.get(element).should('contain.text', text)
})
but when I am using the custom command in my test file I am getting error. I am trying to use the custom command like below
cy.shouldContain(loginPage.loginPageHeaderText, 'Welcome')
The Error I am getting :
Timed out retrying after 60000ms: expected { Object (0, length) } to contain text 'Forgot Password?', but the text was ''