Selecting tomorrow's date from a date picker

1 Answer 288 Views
Test Recording
Adrian
Top achievements
Rank 2
Iron
Iron
Iron
Adrian asked on 21 Mar 2023, 03:18 AM

Hello,

What is the best way to select a date from a Kendo Date picker (Calender).  

Unfortunately you can't enter the date manually in the field, it has to  be selected from the date picker.

Is there any way to find an element by using a variable?

Thanks

Adrian

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivaylo
Telerik team
answered on 22 Mar 2023, 09:22 AM

Hello Adrian,

The best way to select a date from a calendar depends on the specific sceario, what components are used in the application, how these behave, etc. Having this in mind I will need additional details on the case to be able to suggest a feasible approach. 

Usually we recommend to enter the date directly in the calendar input field, so not being able to enter the date manually may complicate the scenario a bit. However, while gathering additional details we'll sort this out. 

Also can you elaborate on what do you mean by finding an element using a variable? If you are asking about using DateTime.Now() and selecting a date I guess it would be possible. But in any case to continue exploring this specific case, I'll need access to the component you are testing. Please, check what options do we have in front to allow us access to the tested application or provide a sample page with the calendar control. 

Please note that you are posting in a public forum where all the information disclosed is publicly available. So if you are going to share any sensitive information, I strongly recommend you to submit a ticket and continue the communication there.

Looking forward to hearing from you.

Regards,
Ivaylo
Progress Telerik

Virtual Classroom is the free self-paced technical training portal that gets you up to speed with Telerik and Kendo UI products including Telerik Test Studio! Check it out at https://learn.telerik.com/.
Adrian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 23 Mar 2023, 12:16 AM

Hi Ivaylo,

The page can only be accesses internally unfortunately but I have attached some screenshots of the date picker and the DOM behind.  It's a kendo control used on our .net application.

I've highlighted the element in the DOM I would need to select if I wanted to select todays date + 1 day which is what I'm looking to do.

Is there anything else I can provide to assist?

Thanks

Adrian

 

 

Ivaylo
Telerik team
commented on 24 Mar 2023, 11:51 AM

Hello Adrian,

Thank you for your update. As I don't have direct access to your application I am not able to provide you with the exact example, but I can provide you with the appropriate workflow. As this cannot be achieved out of the box with Test Studio you can use a coded solution. The idea is to get the current date, add one day to it and use it as a find expression. Here is a sample code snippet:

var tomorrow = DateTime.Today.AddDays(1).ToString("dd");
HtmlAnchor a = Manager.ActiveBrowser.Find.ByAttributes<HtmlAnchor>("tagname=a","InnerText="+tomorrow);
Assert.IsNotNull(a);
a.Click();

This is written against the following public demo: https://demos.telerik.com/kendo-ui/datepicker/index 

For your convenience I am also providing you with the test so you can see how it is everything organized.

Hope this helps.

Regards,
Ivaylo
Progress Telerik

Virtual Classroom is the free self-paced technical training portal that gets you up to speed with Telerik and Kendo UI products including Telerik Test Studio! Check it out at https://learn.telerik.com/.
Adrian
Top achievements
Rank 2
Iron
Iron
Iron
commented on 27 Mar 2023, 01:25 AM

Hi Ivaylo,

This is exactly what I was after, working as I need it to. 

Thankyou

Adrian

Ivaylo
Telerik team
commented on 27 Mar 2023, 08:19 AM

Hello Adrian,

I am glad I was able to assist you.

Should you have any additional questions do not hesitate to contact us.

Best Regards,
Ivaylo
Tags
Test Recording
Asked by
Adrian
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Ivaylo
Telerik team
Share this question
or