【发布时间】:2023-03-28 09:28:01
【问题描述】:
如何在点击 cypress 中的打印按钮时关闭 print window 打开。我正在调用js 函数来关闭窗口并且它没有执行关闭,有人可以建议如何解决这个问题吗?
context('Print button tests', () => {
it.only('Verify the display of Print and close the window', () => {
cy.get('.timetable-filter-panel-button.btn.btn-primary > span')
.contains("Print current view")
.click();
printClose();
})
})
//关闭打开的窗口的Javascript函数:
function printClose(){
window.close();
}
【问题讨论】:
-
@bkucera 你能帮忙解决上述问题吗?
-
AFAIK,你不能,就像你不能在other browser dialogs上操作一样
-
找到这个github.com/cypress-io/cypress/issues/894,唯一的解决办法似乎是这样的。
-
但是我看到了那个解决方案,我想在打开后关闭打印对话框。
-
@soccerway 也许我来晚了,但我遇到了同样的问题,我用下面发布的代码 sn-p 解决了。希望对你有帮助!
标签: javascript cypress