How to Insert a date in a DateTimePicker Repository Item

Ask general questions here.
mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

How to Insert a date in a DateTimePicker Repository Item

Post by mghali » Wed Apr 15, 2015 9:33 pm

I have been trying this for two days now. So any help is a great relief. There is a similar post I put up before.

I have automated tests using a combination of recording and usercodes. For a field that accepts "Set Value- Text" can populate a repository item with the following usercode change.

public void Set_Value_DOB()
{
Report.Log(ReportLevel.Info, "Set Value", "Setting attribute Text to '03/09/1971' on item 'MedicompBeacon.PatientInformation.DOB'.", repo.MedicompBeacon.PatientInformation.DOBInfo);
repo.MedicompBeacon.PatientInformation.DOB.Element.SetAttributeValue("Text",System.DateTime.Now.AddYears(-25).ToShortDateString());
}

Where as the repository item that is a DateTimePicker will not accept set value

public void Set_Value_startDate()
{
Report.Log(ReportLevel.Info, "Set Value", "Set the procedure 'Start Date' to the previous date.", repo.MedicompBeacon.startDateInfo);
repo.MedicompBeacon.startDate.Element.SetAttributeValue("Text", System.DateTime.Now.AddDays(-1).ToShortDateString());
}

When the file is run the report returns,

"Setting attribute 'Text' failed on element '{List:4/15/2015}'.
The operation is not supported. "


How do i fix this please help

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to Insert a date in a DateTimePicker Repository Item

Post by odklizec » Wed Apr 15, 2015 9:49 pm

Hi,

It would be helpful, if you post a Ranorex snapshot of the element in question. You can learn how to create snapshot here...
http://www.ranorex.com/support/user-gui ... files.html

Also, please let us know the version of Ranorex you are using. Have you tried latest 5.3.1?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: How to Insert a date in a DateTimePicker Repository Item

Post by mghali » Thu Apr 16, 2015 2:43 pm

Here is the snapshot. And I am using 5.1.4.
StartDate.rxsnp

I am still working on getting a quote for the new build.

Thank you
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to Insert a date in a DateTimePicker Repository Item

Post by odklizec » Thu Apr 16, 2015 3:00 pm

Hi, the List in question has apparently no "Text" attribute, so this is why it fails. You may try to use AccessibleValue instead? But it may be required to first expand the list to be able to set correct date value?
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: How to Insert a date in a DateTimePicker Repository Item

Post by mghali » Thu Apr 16, 2015 3:29 pm

I am sorry I don't Understand when u say "expand the list". Can you please explain

Also: The dynamic value here is the Start date, it reflects the "current date" of when the file is opened. So it is not 4/15/2015 always. So, I edit the path to find the element irrespective of what date it is and what date the file is created.

Sorry for the inconvineince and questions :|

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to Insert a date in a DateTimePicker Repository Item

Post by odklizec » Thu Apr 16, 2015 3:50 pm

Hi,

The date element looks like a drop down GUI element? What happens if you click that date element? It expands and shows some more controls, right? So if the suggestion with setting the AccessibleValue of List element will not work, you may need to click the List (or its parent startDateTimePicker control) to be able to set the expected date via the additional date picker controls. In other words, it may be not possible to set the date just with SetValue and List element. It's hard to say without seeing your application.

Also, what's the repository path you using for "repo.MedicompBeacon.PatientInformation.DOB" element? To make it date independent, you need to remove [@accessiblename='4/15/2015'] or whatever date is used in path definition. If possible, leave the /list definition without any attribute.

Like this:

Code: Select all

/form[@controlname='ShellForm']//container[@controlname='procedureInformationGroup']/datetime[@controlname='startDateTimePicker']/list
I guess this is what you already did?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: How to Insert a date in a DateTimePicker Repository Item

Post by mghali » Thu Apr 16, 2015 8:22 pm

Yes, I eliminated the List Values. But expanding list did not work. I am not able to make sure that the system picks up a date one previous to existing time. If you can think of anything else let me know.

The repository I am using is "repo.MedicompBeacon.startDate.Element."

Thank you for the help!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to Insert a date in a DateTimePicker Repository Item

Post by odklizec » Thu Apr 16, 2015 8:28 pm

OK, have you tried to use SetAttributeValue with AccessibleValue instead of Text (as suggested in my previous posts)?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mghali
Posts: 26
Joined: Fri Jul 18, 2014 9:05 pm

Re: How to Insert a date in a DateTimePicker Repository Item

Post by mghali » Thu Apr 16, 2015 9:46 pm

Yes I did. It does not return a fail but it niether changes the date.

public void Set_Value_startDate()
{
Report.Log(ReportLevel.Info, "Set Value", "Set the procedure 'Start Date' to the previous date.", repo.MedicompBeacon.startDateInfo);
repo.MedicompBeacon.startDate.Element.SetAttributeValue("AccessibleValue", System.DateTime.Now.AddDays(-1).ToShortDateString());
}

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to Insert a date in a DateTimePicker Repository Item

Post by odklizec » Thu Apr 16, 2015 9:56 pm

This is what I suspected. OK, what exactly happens/appears if you manually click that date picker? Can you create a snapshot of the GUI, which I guess appears after you click the date? You may need to use CTRL+Win key to be able to capture that GUI.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration