I can't share any project code - that's the simplest test that allows to reproduce the problem (almost directly from TestCafe manual):
import { Selector } from 'testcafe';
fixture `Example fixture`
.page `https://start.ro.co/roman/ed`;
test('Example test', async t => {
await t.setNativeDialogHandler(() => true);
});
Tests are failing with:
A native beforeunload dialog was invoked on page "https://start.ro.co/roman/ed", but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.
No dialog is visible, also there weren't any dialogs based on t.getNativeDialogHistory(). After adding setNativeDialogHandler test is failing at exactly this one.
✖ Example test
1) A native beforeunload dialog was invoked on page "https://start.ro.co/roman/ed", but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.
Browser: Chrome 80.0.3987.122 / macOS 10.14.6
18 |
19 |fixture `Example fixture`
20 | .page `https://start.ro.co/roman/ed`;
21 |
22 |test('Example test', async t => {
> 23 | await t.setNativeDialogHandler(() => true);
24 |});
25 |
I attached full debug log below
setNativeDialogHandler should work correctly or above error message shouldn't be displayed ti there aren't any dialogs (according to getNativeDialogHistory)
https://start.ro.co/roman/ed (production environment!)
import { Selector } from 'testcafe';
fixture `Example fixture`
.page `https://start.ro.co/roman/ed`;
test('Example test', async t => {
await t.setNativeDialogHandler(() => true);
});
$ testcafe chrome native-dialog-test.js
Using locally installed version of TestCafe.
Running tests in:
- Chrome 80.0.3987.122 / macOS 10.14.6
Example fixture
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message cmd: 'ready',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message status: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message id: '448.44500004546717',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isCommandResult: false,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message executionError: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message pageError: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message resent: false,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message result: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message consoleMessages: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message null: [Object]
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isPendingWindowSwitching: false
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message disableResending: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message allowRejecting: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message sessionId: 'Ot_UNxAfr'
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message +0ms
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command SetNativeDialogHandlerCommand {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command type: 'set-native-dialog-handler',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command dialogHandler: ExecuteClientFunctionCommand {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command type: 'execute-client-function',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command instantiationCallsiteName: 'setNativeDialogHandler',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command fnCode: '(function(){ return (function () {return true;});})();',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command args: [
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command []
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command ],
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command dependencies: [
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command [Object: null prototype] {}
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command ]
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command +29ms
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message cmd: 'ready',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message status: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message id: '515.4549999861047',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isCommandResult: false,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message executionError: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message pageError: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message code: 'E45',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isTestCafeError: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message callsite: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message dialogType: 'beforeunload',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message pageUrl: 'https://start.ro.co/roman/ed'
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message resent: false,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message result: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message consoleMessages: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message null: [Object]
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isPendingWindowSwitching: false
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message disableResending: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message allowRejecting: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message sessionId: 'Ot_UNxAfr'
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message +2s
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command TestDoneCommand {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command type: 'test-done'
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:command +3ms
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message cmd: 'ready',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message status: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message id: '2242.3499999567866',
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isCommandResult: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message executionError: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message pageError: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message resent: false,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message result: null,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message consoleMessages: {
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message null: [Object]
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message isPendingWindowSwitching: false
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message },
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message disableResending: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message allowRejecting: true,
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message sessionId: 'Ot_UNxAfr'
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message }
testcafe:test-run:Chrome 80.0.3987.122 / macOS 10.14.6:driver-message +2s
✖ Example test
1) A native beforeunload dialog was invoked on page "https://start.ro.co/roman/ed", but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.
Browser: Chrome 80.0.3987.122 / macOS 10.14.6
18 |
19 |fixture `Example fixture`
20 | .page `https://start.ro.co/roman/ed`;
21 |
22 |test('Example test', async t => {
> 23 | await t.setNativeDialogHandler(() => true);
24 |});
25 |
at <anonymous> (/Users/username/testcafe-native-dialog/native-dialog-test.js:23:11)
at <anonymous> (/Users/username/testcafe-native-dialog/native-dialog-test.js:22:1)
at <anonymous> (/Users/username/node_modules/testcafe/src/api/wrap-test-function.js:17:28)
at TestRun._executeTestFn (/Users/username/node_modules/testcafe/src/test-run/index.js:294:19)
at TestRun.start (/Users/username/node_modules/testcafe/src/test-run/index.js:345:24)
1/1 failed (4s)
I've reproduced this issue. We will research it and update this thread as soon as we have any result.
Hello @Dmitry-Ostashev @miherlosev,
any updates here? I'm also spotting this case and it's crucial blocker for us. When tests are unbelievable, unfortunately it undermines their purpose and the effectiveness of the TestCafe.
Please let us know any updates here 🙏
Best regards,
Marcin Łesek
Thank you for bringing this to our attention. We didn't manage to address this issue yet. Once we have any news, we will post them here. Please bear with us.
@AlexanderMoskovkin @Dmitry-Ostashev @miherlosev any updates about the above issue? It is huge for us.
This issue is in our plans, but we cannot provide any estimates at this time.
Facing this issue and it's a major blocker running our tests!! Any update on this issue?
Hopefully this should be taken care.
I cannot reproduce the problem with the latest TestCafe version (1.8.4) and the example written by @tkonieczny.
It looks like the tested site was changed. Guys, could anybody create an example so that we can reproduce the problem again?
This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.
Most helpful comment
Hello @Dmitry-Ostashev @miherlosev,
any updates here? I'm also spotting this case and it's crucial blocker for us. When tests are unbelievable, unfortunately it undermines their purpose and the effectiveness of the TestCafe.
Please let us know any updates here 🙏
Best regards,
Marcin Łesek