Page 1 of 1

How to Insert a date in a DateTimePicker Repository Item

Posted: Wed Apr 15, 2015 9:33 pm
by mghali
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

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

Posted: Wed Apr 15, 2015 9:49 pm
by odklizec
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?

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

Posted: Thu Apr 16, 2015 2:43 pm
by mghali
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

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

Posted: Thu Apr 16, 2015 3:00 pm
by odklizec
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?

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

Posted: Thu Apr 16, 2015 3:29 pm
by mghali
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 :|

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

Posted: Thu Apr 16, 2015 3:50 pm
by odklizec
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?

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

Posted: Thu Apr 16, 2015 8:22 pm
by mghali
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!

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

Posted: Thu Apr 16, 2015 8:28 pm
by odklizec
OK, have you tried to use SetAttributeValue with AccessibleValue instead of Text (as suggested in my previous posts)?

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

Posted: Thu Apr 16, 2015 9:46 pm
by mghali
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());
}

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

Posted: Thu Apr 16, 2015 9:56 pm
by odklizec
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.