microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
513 stars 286 forks source link

[BUG] Issue with entering dates, possibly because of SetValue #1225

Open sarahliTC opened 2 years ago

sarahliTC commented 2 years ago

Bug Report

Issues should only be created for items related to covered functionality.

Not covered functionality, feature requests, and questions should use the Feature Request or Question templates.

EasyRepro Version

UCI or Classic Web

Online or On Premise

Browser

Describe the bug

We are having issues with entering/selecting dates in our Dynamics 365 app. We have tried many methods and it still would not work.

Behavior 1: The page keeps on refreshing and getting stuck on entering the Start Time, it seems like it is not even reaching the End Time field and entering data: date entry bug 1

Behavior 2: It can enter both the Start Time and End Time in chronological order, however it takes multiple attempts to do so, in weird ways (for example, entering "2021-10-22" immediately after entering "2021/10/22" in the same entry field): SUC13 date entry bug 2 SUC 13 date entry bug 3

Error Message in Visual Studio: Test method Microsoft.Dynamics365.UIAutomation.Sample.UCI.Create.CreateBasicInfo.UCICreateBooking threw exception: System.InvalidOperationException: Timeout after 10 seconds. Expected: 2021-10-22. Actual: 2021/10/22

Special formatting / display

Code to reproduce
We have tried a variety of formats, they all do not work:

Attempt 1: Using SetValue(string field, string value)

DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddMonths(3);    // a future date

xrmApp.Entity.SetValue("starttime", startDate.ToString("yyyy/MM/dd"));    // also tried with format "yyyy-MM-dd
// after entering starttime, endtime will be automatically filled, so clear it first
xrmApp.Entity.ClearValue("endtime");
xrmApp.Entity.SetValue("endtime", endDate.ToString("yyyy/MM/dd"));

Attempt 2: Using SetValue(string field, DateTime date, string formatDate = null, string formatTime = null)

DateTime startDate = DateTime.Now;
DateTime endDate = startDate.AddMonths(3);

xrmApp.Entity.SetValue("starttime", startDate, "yyyy/MM/dd");
xrmApp.Entity.ClearValue("endtime");
xrmApp.Entity.SetValue("endtime", endDate, "yyyy/MM/dd");

Attempt 3: Using SetValue(DateTimeControl control)

DateTimeControl startDate = new DateTimeControl("starttime") { Value = DateTime.Today };
DateTimeControl endDate = new DateTimeControl("endtime") { Value = DateTime.Today.AddMonths(3) };

xrmApp.Entity.SetValue(startDate);
xrmApp.Entity.ClearValue("endtime");
xrmApp.ThinkTime(2000);
xrmApp.Entity.SetValue(endDate);

Attempt 4: Using ThinkTime() before setting the values, and then after setting the values. For example this code snippet below. Have tried this for all the methods above with no luck

// before setting the values
xrmApp.ThinkTime(2000);    // <--
xrmApp.Entity.SetValue(startDate);
xrmApp.Entity.ClearValue("endtime");
xrmApp.ThinkTime(2000);    // <--
xrmApp.Entity.SetValue(endDate);

// after setting the values
xrmApp.Entity.SetValue(startDate);
xrmApp.ThinkTime(2000);    // <--
xrmApp.Entity.ClearValue("endtime");
xrmApp.Entity.SetValue(endDate);
xrmApp.ThinkTime(2000);    // <--

Attempt 5: Putting hours and minutes in the format, for example:

xrmApp.Entity.SetValue("starttime", startDate, "yyyy/MM/dd", "HH:mm");

Expected behavior

Assuming End Time > Start Time.

  1. Enter Start Time
  2. End Time gets filled in automatically (by our Dynamics 365 app), right now End Time = Start Time, we want to clear it in the next step
  3. Clear the End Time field
  4. Enter End Time
  5. Save the Form and go back to the page it came from, with no errors

The page and date picker should not keep on looping/refreshing when entering the 2 dates. One a date is entered, it should move on to the next step (i.e. once Start Time is entered it should move on to End Time, and once End Time is entered it should save the form).

Screenshots
Please refer to the GIFs and code snippets above.

Additional context
Please refer to the "Code to reproduce" section above to see the methods we have tried.

alonsoatunicc commented 1 year ago

Hi.

I've got the same behavior as described in "Behavior 1" with two new fields in Quote entity: Start date and End date. It seems like the automation is stuck in the Start date.

Any news regarding this issue?

Thank you.

// update

I have a test case that runs successfully and creates two opportunities in a row. I´ve added some code to set a value in the Est. Close Date:

  1. to a specific date, like 06/30/2023
  2. to a calculated date, like Today.AddDays(1)

When running the test it starts looping in this date field, going back to the Est. Close Date over and over. Other fields can be set using the SetValue sentence, including LookUps and OptionSets. I´ve only got this behavior with date fields.

SetValue is an overloaded function. I´m wondering if the corresponding SetValue function for DateTime fields has some missing code...

Thank you.

alonsoatunicc commented 1 year ago

I've finally found a solution.

Instead of using a DateTime field, I've set the date as text value directly, as follows:

// Date format MM/DD/YYYY
// Date is sent as text to be able to assign a date to fields
xrmApp.Entity.SetValue("startdate", "6/1/2023");
xrmApp.Entity.SetValue("enddate", "6/30/2023");

This works for me. Thank you