Testing TestCaf&xE9;本机对话框处理程序偶尔不工作

Testing TestCaf&xE9;本机对话框处理程序偶尔不工作,testing,automated-tests,e2e-testing,testcafe,web-testing,Testing,Automated Tests,E2e Testing,Testcafe,Web Testing,我有一个测试,我试图删除一个文件。此时会出现一个本机对话框,测试将断言对话框中的文本是否包含我期望的字符串。测试偶尔会无缘无故地失败,我无法调试它,因为我无法看到对话框是否显示,因为TestCafé正在处理它 test('Verify that an account owner sees a warning when deleting the winning media in a Completed A/B test', async (t) => { const projectTit

我有一个测试,我试图删除一个文件。此时会出现一个本机对话框,测试将断言对话框中的文本是否包含我期望的字符串。测试偶尔会无缘无故地失败,我无法调试它,因为我无法看到对话框是否显示,因为TestCafé正在处理它

test('Verify that an account owner sees a warning when deleting the winning media in a Completed A/B test', async (t) => {
   const projectTitle = "advancedaccount's First Project";
   const completedMediaName = 'Cmpltd Control'; // winning media

   await t
     .useRole(advancedAccount)
     .click(projectListPage.projectLink.withAttribute('title', projectTitle))
     .click(projectPage.mediaLink.withText(completedMediaName))
     .setNativeDialogHandler(() => false)
     .hover(mediaPage.videoActionsDropdown)
     .click(mediaPage.actions.delete)
     .expect(getLocation()).contains('medias');

  const history = await t.getNativeDialogHistory();

  await t
     .expect(history[0].text).contains('This media is also the winner of an A/B test');
});
故障诊断:

1) TypeError: Cannot read property 'text' of undefined

    54 |    .expect(getLocation()).contains('medias');
    55 |
    56 |  const history = await t.getNativeDialogHistory();
    57 |
    58 |  await t
  > 59 |    .expect(history[0].text).contains('This media is also the winner of an A/B test');
    60 |});
    61 |

你知道会出什么问题吗,或者我该如何找出问题的症结所在?

我发现历史记录数组为空的两个可能原因:

  • testcafe端有一个bug
  • 由于web应用程序端出现问题,本机对话框不会尝试显示

  • 要确定问题的真正原因,我们需要一个指向您的web应用程序的链接或一个简单的项目,我们可以在其上重现此行为。

    我不确定让您访问我们的应用程序的简单方法是什么,因为它在用户登录之后。我可以告诉你的是,现在我想起来,本机对话框肯定出现了,并且肯定得到了正确的处理,因为否则
    .expect(getLocation()).contains('media')
    将失败。这是我的故障保险,以确保正确采取行动。似乎只是历史并没有像预期的那样起作用。我在测试中排序的方式可能有问题吗?请检查本机对话框是否总是显示在测试页面上而没有TestCafe。要检查对话框是否在测试执行期间显示,您可以在
    setNativeDialogHandler
    操作
    .setNativeDialogHandler(()=>{debug;return false;})中记录或调试本机对话框的处理程序。
    如果显示了对话框,但历史记录中没有关于它的条目,则它是一个错误。请在TestCafe GitHub repo中创建。您必须为bug报告填写一个完整的模板,包括一个复制行为的示例:整个测试和测试页面URL。因此,如果您提供临时测试凭据以进入页面,那就太好了。