Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

javascript - How to create custom dialog in Cypress

I am working with a custom command in cypress that pauses the test and opens a window.prompt() that asks the user for some input and adds it to the mochawesome report with the addcontext command. However, I want to create my own custom dialog that has a textbox and two buttons - pass/fail (basically a combination of window.prompt() and window.confirm()). Is there some way I can create my own html element and display it in cypress?

question from:https://stackoverflow.com/questions/66066106/how-to-create-custom-dialog-in-cypress

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Solved. I injected html into the dom through Cypress.$(body).append(... and then accessed the elements through jquery. I used waitUntil and cy.focused as well as the regular jquery button focus events to pause execution of the test and resume after the pause or fail buttons were pressed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...