cypress-io / cypress-example-recipes

Various recipes for testing common scenarios with Cypress

Home Page:https://on.cypress.io/examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add example for stubbing typing username and password into window.prompt

SofiulAlam opened this issue · comments

Hi,

I am very new to Cypress and spend half days looking examples on how to send text in prompt.
I have tried below code but getting error.
cy.visit('http://localhost:3000')
cy.window().then((win) => {
cy.stub(win, 'prompt').returns('username', 'password')
})

Requirements:

I need to enter username and password and click the window prompt submit button or close the window without entering username and password . Any ideas please?

Thanking you in advanced.

Kind Regards,

Sofiul