Samantha Blasbalg
Samantha Blasbalg

Reputation: 749

TestCafé Native Dialog Handler sporadically not working

I have a test in which I try to delete a file. A native dialog appears, and the test asserts whether the text in the dialog contains the string that I expect. Sporadically the test fails for seemingly no reason, and I can't debug it because I can't actually see whether the dialog shows up or not since TestCafé is handling it.

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');
});

Failure diagnostic:

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 |

Any idea what could be going wrong, or how I can try to get to the bottom of it?

Upvotes: 3

Views: 558

Answers (1)

aleks-pro
aleks-pro

Reputation: 1669

I see two possible causes of the fact that the history array is empty:

  1. There is a bug on the testcafe side.
  2. Native dialog does not attempt to show up because of a problem on the web application side.

To determine the real cause of the problem we need a link to your web app or a simple project on which we will be able to reproduce this behavior.

Upvotes: 3

Related Questions