Javascript Cypress:单击粘贴流
当我点击一个触发提示窗口的按钮时,流程卡在这里,我什么也做不了。有什么问题吗Javascript Cypress:单击粘贴流,javascript,iframe,cypress,Javascript,Iframe,Cypress,当我点击一个触发提示窗口的按钮时,流程卡在这里,我什么也做不了。有什么问题吗 it('Test case', () => { cy.get('iframe').iframe(() => { cy.get('.button').eq(0).click(); }); // Process stopping here cy.contains('Please enter data').click() cy.on('window:confirm', (str)
it('Test case', () => {
cy.get('iframe').iframe(() => {
cy.get('.button').eq(0).click();
});
// Process stopping here
cy.contains('Please enter data').click()
cy.on('window:confirm', (str) => {
expect(str).to.equal('Please enter data')
})
cy.on('window:confirm', () => true);
});
cy.on(事件,回调)
将只捕获预定义的事件(请参阅)
你可能想改成
it('调用了测试窗口确认',()=>{
const win=cy.state(“窗口”)
cy.stub(赢得“确认”)
cy.get('iframe').iframe(()=>{
cy.get('.button').eq(0).单击();
});
cy.window().its('confirm')。应该('be.calledWith','Please enter data'))
});
用柏树小提琴测试
//
常数测试={
html:`
`,
测试:`
const win=cy.state(“窗口”)
cy.stub(赢得“确认”)
cy.get('button')。单击()
cy.window().its('confirm')。应该('be.calledWith','testmessage')//通过
`
}
它('运行测试',()=>{
cy.runExample(测试)
})