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
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/.
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.
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();
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/.