I am trying to login to the application but it says "A native alert dialog was invoked on page", I tried manually and could not see any dialog box

Viewed 19

I am new to test cafe. I am trying to login to the application but it says " A native alert dialog was invoked on page, but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.", I tried manually and could not see any dialog box.

page and function to login

import { Selector } from 'testcafe';

class Page {
    constructor () {
        this.loginInput    = Selector("input[name*='username']");
        this.passwordInput = Selector("input[name*='password']");
        this.submitButton  = Selector("div[role=button] div[class='gw-label']");
    }

    async login (t) {
        await t
            .maximizeWindow()
            .typeText(this.loginInput, 'testRole')
            .typeText(this.passwordInput, 'P@ssw0rd')
            .setNativeDialogHandler(() => true)
            .click(this.submitButton);

        await t.wait(2000)
        .expect(Selector("div[class = 'gw-TitleBar--title']").innerText).contains('Dashboard');
    }
}

export default new Page();

Test: Test image

website backend code: backend code

enter code here
0 Answers
Related