microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.61k stars 3.57k forks source link

[Bug]: Confirmation Dialog within page frame not handled in Playwright #32267

Closed kjadhav-wk closed 2 weeks ago

kjadhav-wk commented 3 weeks ago

Version

1.45.3

Steps to reproduce

Confirmation dialog box is not populating when we change the value from the dropdown. I have attached the screenshot of the page. Actually, this is old legacy page where dialogs are embedded in the page not at browser level. Below is the code snippet which I use to handle- const waitForDialog = page.waitForEvent('dialog'); await usersUi.goToUserPage(testData.user.code); await usersUi.profile.userTypeSelect.selectOption({ label: data.userType }); const confirmDialog = await waitForDialog ; expect(confirmDialog.message()).toBe(testData.expectedWarningMessage);

Expected behavior

Confirmation dialog should be handled and dialog message should be correct Dialog .

Actual behavior

Confirmation dialog is not appearing.

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
    Memory: 11.85 GB / 31.78 GB
  Binaries:
    Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.92.0 - C:\Users\krishnakant.jadhav\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 5.2.15 - C:\windows\system32\bash.EXE
  npmPackages:
    @playwright/test: ^1.45.3 => 1.45.3
Skn0tt commented 3 weeks ago

Hi Krishnakant! Could you provide us with a reproduction repo so we can take a look at what's going wrong?

Skn0tt commented 3 weeks ago

On a second thought: You're waiting for the "dialog" event, but that's about dialogs at browser level.

Instead of waiting for the dialog to pop up, you can assert that it has the correct contents using expect(page.getByText(testData.expectedWarningMessage)).toBeVisible();.

Let me know if that helped!

kjadhav-wk commented 3 weeks ago

It is real time application code. It cannot be share outside the organization. Just to tell you the issue when we select value from drop down then confirmation dialog is not popping up. And it is within classic frame not browser level.

Skn0tt commented 3 weeks ago

The confirmation dialog not popping up when it should sounds like a bug within your application, not within Playwright. Have you given expect(...).toBeVisible() a try?

kjadhav-wk commented 3 weeks ago

Yes. Tried it is not working. Manually, when we change then confirmation dialog is popping but when we try via Playwright it is not working. I have attached some screenshot. Maybe that will help you.

image image

Skn0tt commented 3 weeks ago

I understand you can't share the application code, but I can't figure out what's going on based off that screenshot. We'll need a minimal reproduction, otherwise it's impossible for us to debug and help you.

Skn0tt commented 3 weeks ago

You can also try generating code for this using codegen: https://playwright.dev/docs/codegen#running-codegen

Skn0tt commented 2 weeks ago

I'll go ahead and close. If you think you found another bug, feel free to open another issue an provide a repro :D