microsoft / EasyRepro

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

[BUG] Required fields check is not working when saving the records #1215

Open OlhaKucheriava opened 2 years ago

OlhaKucheriava commented 2 years ago

Bug Report

EasyRepro Version EasyRepro-develop-2021ReleaseWave2

UCI or Classic Web

Online or On Premise

Browser

Browser

Describe the bug
Run the test case with the code below. Or have any other test case, where you create a record and do not fill in the required field on the form and save this record

Code to reproduce
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license.

using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Dynamics365.UIAutomation.Api.UCI; using Microsoft.Dynamics365.UIAutomation.Browser; using System; using System.Security;

namespace Microsoft.Dynamics365.UIAutomation.Sample.UCI { [TestClass] public class CreateAccountUCI {

    private readonly SecureString _username = System.Configuration.ConfigurationManager.AppSettings["OnlineUsername"].ToSecureString();
    private readonly SecureString _password = System.Configuration.ConfigurationManager.AppSettings["OnlinePassword"].ToSecureString();
    private readonly SecureString _mfaSecretKey = System.Configuration.ConfigurationManager.AppSettings["MfaSecretKey"].ToSecureString();
    private readonly Uri _xrmUri = new Uri(System.Configuration.ConfigurationManager.AppSettings["OnlineCrmUrl"].ToString());

    [TestMethod]
    public void UCITestCreateAccount()
    {
        var client = new WebClient(TestSettings.Options);
        using (var xrmApp = new XrmApp(client))
        {
            xrmApp.OnlineLogin.Login(_xrmUri, _username, _password, _mfaSecretKey);

            xrmApp.Navigation.OpenApp(UCIAppName.Sales);

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

            xrmApp.CommandBar.ClickCommand("New");

            xrmApp.Entity.SetValue("address1_name", TestSettings.GetRandomString(5,15));

            xrmApp.Entity.Save();
            xrmApp.ThinkTime(5000);

        }

    }
}

} -->

Expected behavior
test case should fail as required fields are not filled in

Actual behavior: test case is marked as passed even though the record was not saved,

jkanschik commented 2 years ago

Maybe the following enhancement of the test case would help (it did for me at least):

  xrmApp.Entity.Save();
  var notification = client.Browser.Driver.FindElement(By.XPath("//span[@data-id='warningNotification']"));
  Assert.Equal("Topic : Required fields must be filled in.", notification.Text);

This allows you to actually check the correct warning message and you have actually more control over your test case.

OlhaKucheriava commented 2 years ago

Maybe the following enhancement of the test case would help (it did for me at least):

  xrmApp.Entity.Save();
  var notification = client.Browser.Driver.FindElement(By.XPath("//span[@data-id='warningNotification']"));
  Assert.Equal("Topic : Required fields must be filled in.", notification.Text);

This allows you to actually check the correct warning message and you have actually more control over your test case.

Yes. I know the workaround, thanks! I just think that this bug should be fixed as this could create false passed test cases for some users and they will never know it.