Search code examples
geolocationautomated-testse2e-testingweb-testingtestcafe

TestCafe setNativeDialogHandler for Location access


I can't get the function setNativeDialogHandler to close chrome's "Know Your Location" dialog. Here's how I call it:

await t
  .typeText(this.rallyPostUpdateField, message, { paste: true, replace: true })
  .setNativeDialogHandler(() => true)
  .click(this.rallyPostUpdateSubmitButton);

The user enters some text into an input, then when clicking a submit button, the "Know your location" pop-up shows up. I even tried calling setNativeDialogHandler after the click:

await t
  .typeText(this.rallyPostUpdateField, message, { paste: true, replace: true })
  .click(this.rallyPostUpdateSubmitButton)
  .setNativeDialogHandler(() => true)

No luck. Am I doing something wrong here?


Solution

  • At present, TestCafe doesn't allow you to handle the 'Know your location' dialog out of the box.
    Track this issue to know when this feature will be implemented.
    In the meantime, you can consider using a workaround from https://github.com/DevExpress/testcafe/issues/1991#issuecomment-350284141.