microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
521 stars 288 forks source link

Unable to confirm delete of a record using Dialogs.ConfirmationDialog, latest WAVE changes possibly!? #1305

Open mrmwink opened 2 years ago

mrmwink commented 2 years ago

EasyRepro Version

UCI or Classic Web

Online or On Premise

Browser

Describe the bug
When calling delete on an any Table (account used in this example) the confirmation dialog appears but using xrmApp.Dialogs.ConfirmationDialog(); with either true or false does nothing. Having a look at the code the xpath is looking for is "//*[@id=\"confirmButton\"]" but the HTML of the page it appears that the xpath is now "//*[@data-id=\"confirmButton\"]".

I'm very new to this so I did manually change the code locally and it works but am unaware of any knock on effect of the change might have and wasn;t sure if this was related to the latest WAVE release and therefore whether it's in hand but I couldn't find another issue here but find it hard to believe no one else has experienced the same.

Code to reproduce

csharp
                xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecretKey);

                xrmApp.Navigation.OpenApp(UCIAppName.Sales);

                xrmApp.Navigation.OpenSubArea("Sales", "Accounts");

                xrmApp.Grid.OpenRecord(0);

                xrmApp.CommandBar.ClickCommand("Delete");

                xrmApp.Dialogs.ConfirmationDialog(false);

-->

Expected behavior
Dialog should close either having Delete or Cancel clicked

Shakevg commented 2 years ago

mrmwink It is related to D365 changes in build 9.2.22052.152 I had this same bug, but I came up with a workaround that might work for you while we wait to get it fixed. I added these lines to my code to override the values in Microsoft.Dynamics365.UIAutomation.Api.UCI\DTO\AppElementReference.cs

AppElements.Xpath[AppReference.Dialogs.ConfirmButton] = "//*[@data-id=\"confirmButton\"]";
AppElements.Xpath[AppReference.Dialogs.CancelButton] = "//*[@data-id=\"cancelButton\" or @data-id=\"errorOkButton\"]";

You should add this code to any Init method depending on your test Framework. For MSTEST: AssemblyInitialize (it is the best), ClassInitialize, TestInitialize

mrmwink commented 2 years ago

Hi, yes that's the one, I made the exact same change myself yesterday, not sure if this is the corect solution hence my raising it in case I was missing something at a lower level in the code base!

Thanks