This is a migrated thread and some comments may be shown as answers.

Automation tests with RadDateTimePicker produces exception

2 Answers 137 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 13 Feb 2015, 02:09 PM
Hi,

I'm currently trying to populate a RadDateTimePicker control with data during an automation test (using the Microsoft automation tests framework). I've succeeded in populating edit controls using the ValuePattern.Pattern - but using this with the RadDateTimePicker fails. The C# test code is (where HostAutomationElement is the root element of the ApplicationUnderTest):

string theDateWeNeedToSetAsAString = "01/01/2015";
HostAutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "StartDate"))
ValuePattern valuePattern = StartDateDatePickker.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valuePattern.SetValue(theDateWeNeedToSetAsAString);

<telerik:RadDateTimePicker x:Name="StartDate"
                       Width="200" HorizontalAlignment="Left"
                       InputMode="DatePicker"
                       SelectedValue="{Binding StartDate, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                       AutomationProperties.AutomationId="TheStartDate"/>


The error I get is an ElementNotAvailableException and the inner exception of this says: "Operation is not valid due to the current state of the object." which is fired from :at System.Windows.Automation.ValuePattern.SetValue(String value)

Is there an alternative pattern I should be using for this?  Enumerating the available patterns for the control gives me:

ValuePatternIdentifiers.Pattern
ExpandCollapsePatternIdentifiers.Pattern
SynchronizedInputPatternIdentifiers.Pattern

I don't want to expand/collapse - and the SynchronizedInputPattern seems too low level. Is there something else I have to do to get data into the RadDateTimePicker control within a test environment?

Cheers,
Tom.

2 Answers, 1 is accepted

Sort by
0
Tom
Top achievements
Rank 1
answered on 13 Feb 2015, 02:14 PM
Just noticed that in the post above I have detailed the automation id as TheStartDate whilst the C# refers to StartDate - which, of course, in my original source code is not the case. The two match and the element is retrieved successfully. Only when calling the SetValue on the valuePattern do I get a thrown exception - and no update to the RadDateTimePicker.
0
Georgi
Telerik team
answered on 16 Feb 2015, 11:40 AM
Hi Tom,

Indeed the pattern you need in order to set the value of the DateTimePicker is the ValuePattern and so far we are not aware of any issues similar to the one you are facing.

So we have tested it with the UI Spy tool and with the sample code you have provided (as shown in the attached project), but we were not able to reproduce the exception.

Therefore it would be great if you can check out the project and let me know if I have missed something. If so it would be helpful if you can send us a sample project that demonstrates the exception.

Looking forward to your replay.

Regards,
Georgi
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DatePicker
Asked by
Tom
Top achievements
Rank 1
Answers by
Tom
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or