1

I have been working with CodedUI in a bootstrap UI, which my currently working solution is built on.

I recently noticed when automating the functionalities for a Smoke test, the recorded steps (CUI using VS2013) for business functionality (creating a budget period) where a date picker involves in, the automate execution keep getting failed after clicking on the dropdown on date picker (when running the test method).

I recorded several times and tried to recreate this issue and I figured out, that the default selected date in the picker must be the date which was there when the test method was recording to run the method.

In any-case if I run the test method after few days from the recording date, since the date picker always gets the current (system date) as the preselected date, the execution of the test method fails from that point onwards (unless if I manually chose the date which i recorded the test method from the date picker).

I tried eliminating the test property (inner text) where it spies for the preselected date from the UIMap, but I was unable to find a proper solution for it.

If there is any CodedUI fluent person who has dealt with a bootstrap Datepicker earlier can you kindly assist me?

Or if anyone knows how to eliminate a search property from spying for a UI property, (only if it is a ethical attempt), will anyone be able to kindly assist me?

Code Snipets:

Image 1 : UIMap.Designer.cs UIMap.Designer.cs

Image 2 : UIStartDateEdit Class in UIMap.Designer.cs UIStartDateEdit Class in UIMap.Designer.cs

Image 3 : AddBudgetParams Class in UIMap.Designer.cs AddBudgetParams Class in UIMap.Designer.cs

Image 4 : UIItemTable Method and UIItem1Cell in UIMap.Designer.cs UIItemTable Method and UIItem1Cell in UIMap.Designer.cs

hirosht
  • 932
  • 2
  • 17
  • 31
  • 1
    Find `UIStartDateEdit` in the UI Map editor and look at its initialising (or default) value. Then use the ideas from data driving to write a new value there. The assignment goes in your `[TestMethod]` before the call of `AddBudget`. – AdrianHHH Aug 05 '15 at 10:05
  • @AdrianHHH I have uploaded the coded snippet of `UIStartDateEdit`. There i was unable to find for an initialization of the default date. Will you be able to assist me further, please? – hirosht Aug 05 '15 at 10:32
  • 1
    There should also be classes such as `AddBudgetParams` and `AddBudgetExpectValues`. What do they contain? – AdrianHHH Aug 05 '15 at 10:59
  • @AdrianHHH I have added the code snippet of the `AddBudgetParam` in `UIMap.Designer.cs` to the question above for your reference. But in `AddBudgetParam` class there is no variable which holds the _start date_. Meanwhile there is NO class called `AddBudgetExpectValues` in `UIMap.Designer.cs` as you mentioned, – hirosht Aug 05 '15 at 11:23
  • @AdrianHHH will you be able to assist me further, if its not a trouble to overcome from the issue I'm facing, Please? – hirosht Aug 06 '15 at 02:45
  • 1
    The "start date" field in the image shows "1 Aug 2015". I have not seen your code but I have tried to get you to search for it and to tell you the likely places. You need to find where or how that is set. Once you have found the date the next steps should be easy. – AdrianHHH Aug 06 '15 at 08:06
  • @AdrianHHH As shown in Code Snippet Image 4, I found the two places where the `innertext` is holding the two parts of the _Date_ and _MonthYear_. ( as highlighted in yellow). Do you have any idea or a suggestion on how to eliminate the `innertext` atleast? Tried Commenting the `innertext` and it fails the execution(run). At-least If I can eliminate the `innertext`, or else do you know any better solution for my requirement? Please be kind to assist me if, I hope I'm not troubling you – hirosht Aug 06 '15 at 09:10

1 Answers1

0

I suggest searching the UIMap.designer.cs file for the date when the recording was made. If found then add code to the test method to overwrite the date with the date of the test run. Read the "Read the CSV fields and use them in the test" part of this answer, but replace the TestContext.DataRow... parts with the date in the required format.

Community
  • 1
  • 1
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
  • I am facing a similar issue with Coded UI and Date picker, can you have a look over this issue and sugeest what can be its solution http://sqa.stackexchange.com/questions/16409/coded-ui-test-cases-taking-too-much-time-to-execute – Dhiman Jan 26 '16 at 20:14