我刚收到这种类型的警报,却不知道如何用赛普拉斯处理它
基本上,我认为从文档中看,赛普拉斯会自动接受警报,但发现警报出现时,赛普拉斯窗口却被卡住了
我尝试了一些在线阅读的解决方案,但都无济于事。像下面这样的
cy.on('window:confirm', str => {
expect(str).to.eq('do you swear you are a legitimate user and intend to act honestly?')
})
正如他们所说,如果这个返回true或不返回任何东西,它将起作用。但实际情况并非如此。
it('interceptorTrigger', () => {
cy.visit('http://localhost:9009/?path=/story/loginwithemail--interceptortrigger')
cy.getIframe('#storybook-preview-iframe')
.find('button')
.click()
cy.on('window:confirm', str => {
// expect(str).to.eq('do you swear you are a legitimate user and intend to act honestly?')
})
cy.wait(2000)
cy.log('done')
})
答案 0 :(得分:0)
在致电cy.on('window:confirm',...)
之前尝试定义您的click()
查看"Catalog of Events" API文档页面 如果您向下滚动到Examples > Window Confirm,它将显示如何拦截呼叫并对其进行断言:
// Define
cy.on('window:confirm', (str) => {
expect(str).to.eq('first confirm')
// return false to deny
})
// THEN click
cy.get('button').click()
还可以分享getIframe()
函数的外观吗?