2 years ago
#41491

GedeAl
in Cypress i can not make the command 'promt' to work
I am doing API testing with Cypress and I want to have a prompt that asks for a value. I use a function to try to get the value.
The commands: Alert and Confirm shows a popup windows, but Prompt (or window.prompt) does not work (nothing shows/no error message)
How can I get the Prompt to work?
My tests are:
Image:
Here is the code:
/// describe('Example to demonstrate handling of JavaScript Alerts, Confirm, Prompt in Cypress', () => { console.clear()
it('get answer ', () => {
var answer = window.confirm("Would like to confirm?");
if (answer) {
console.log('YES')
}
else {
console.log('NO')
}
});
it('get answer ', () => {
var name = alert("Your name is Null");
console.log(name)
});
it('get answer ', () => {
var name = prompt("What is your name?");
console.log("Hi " + name)
});
})
cypress
prompt
0 Answers
Your Answer