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.
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.