Automated tests setNativeDialogHandler处理ie11访问剪贴板

Automated tests setNativeDialogHandler处理ie11访问剪贴板,automated-tests,internet-explorer-11,clipboard,e2e-testing,testcafe,Automated Tests,Internet Explorer 11,Clipboard,E2e Testing,Testcafe,我有一个测试,可以启动一个拷贝到剪贴板。在ie11中,生成一个对话框 我不能清除它。这是我的密码 fixture.only`Downloads` .page`${page.page}` .beforeEach(async (t) => { await t .maximizeWindow() .setNativeDialogHandler((type, text, url) => {

我有一个测试,可以启动一个拷贝到剪贴板。在ie11中,生成一个对话框

我不能清除它。这是我的密码

fixture.only`Downloads`
    .page`${page.page}`
    .beforeEach(async (t) => {
        await t
            .maximizeWindow()
            .setNativeDialogHandler((type, text, url) => {
                if (type === 'confirm') { return false } return true
            })
        await page.loginAdmin()
    })
    .afterEach(async (t) => {
        await t.setNativeDialogHandler(null)
    })
但它不会清除对话框。我也试过了

.setNativeDialogHandler(() => true)

但是对话框仍然存在,测试超时

您可以使用以下方法进行剪贴板交互:


另请参见:

尝试以下线程中的解决方案:IE->Internet选项->安全->Internet区域->自定义级别->允许编程剪贴板访问。谢谢这将解决出现的对话框。然后我需要确定如何以这种方式配置IE。我可以快照一个配置为本地测试的testVM。。。我将不得不研究如何让saucelabs(浏览器测试服务)为我提供具有该配置的ie11。在这种情况下,我建议您等待TestCafe支持剪贴板开箱即用:
const overrideClipboardCopy = ClientFunction(() => {
    const execCommand = document.execCommand;

    document.execCommand = (action, ...args) => {
        if (action === 'copy') {
            //handle copy here
        }
        else
            return execCommand.call(document, ...args);
    }
});