Will a coded step work for this?

1 Answer 18 Views
Coded Steps General Discussions Test Execution Test Recording
Steve
Top achievements
Rank 1
Iron
Steve asked on 19 Jun 2021, 02:58 PM

I have an Angular Material Datepicker that has a couple of issues.  The Start input has been saddled with a dynamic id (Dp1623875848Text), and I cant remove it(dependency).

I was thinking, since it still had a name="date-start" attribute, I could tie it to DateStartText in my entity repository. So, before I journey down a long road of futility, is coded step an option for fixing this?

 

My second issue with the datepicker, it is inconsistent about making it into the capture. If I bypass the calendars and directly type in the dates, they show up in the capture. If I select it through the calendars, they wont show in the capture. I suspect this a timing issue, but the dates are in steps 2 and 3. So, I'm not sure how fix that.

 

Steve

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 23 Jun 2021, 02:15 PM

Hi Steve,

Thank you for sharing thorough details on the encountered difficulty with the calendar control. 

I searched the web for an example with such type of calendar and found this one here. As far as I understand you need to add a range of dates and use the two inputs nested in the calendar view. Probably the control in the application you are testing differs from the example, but still this was helpful for me to understand the structure. 

Based on what I found in the sample page, you will need to modify the find expressions of the two inputs for start and end date without the need of a coded step. When recording an element, Test Studio automatically generates find expression for the element and this is how the element is being identified on the page during the test execution. If this expression is using any attribute, which is dynamically changing, the element will not be found when running the test. So, if this happens, you can modify the generated find expression manually by editing the element and change the attributes used in it

In addition to that, you can modify the list and order of attributes, which will be used in the automatic generation of find expressions. For example, if the ids in the tested application are dynamic, you can't rely on them for identifying the elements during test run-time. So, you can change the order of attributes in the Project Settings -> Find Logic tab. You can add custom attributes in this list as well. 

Since I had an example page, I prepared a sample test for you (you can find it attached), in which you can revise the recorded elements. The find expressions were manually edited actually - the start date input was initially recorded with id, and the end date was added with a chained find expression. Since these expressions were not completely reliable, I edited the two elements and used the attributes placeholder and formcontrolname as these are unique for the two inputs. For this particular example, I left the chained find expression because there are few examples listed on the page and if not using a parent element, the elements may match a different example. 

To review the test, you can add it in a project by using the Add existing test option in the project context menu. 

As to the general approach to handle calendar date pickers - I recommend you stick to entering the desired date manually in the input field. Otherwise, you can't easily control which month will be listed in the calendar popup next time the test is executed, so that you know what date need to be selected. 

I hope this information will help you sort out the elements in the tested page and modify these accordingly. Let me know if you need any further assistance on the case.

Regards,
Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Tags
Coded Steps General Discussions Test Execution Test Recording
Asked by
Steve
Top achievements
Rank 1
Iron
Answers by
Elena
Telerik team
Share this question
or