Automation tests with RadDateTimePicker produces exception

3 posts, 0 answers
  1. Tom
    Tom avatar
    2 posts
    Member since:
    Aug 2014

    Posted 13 Feb 2015 Link to this post

    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. Tom
    Tom avatar
    2 posts
    Member since:
    Aug 2014

    Posted 13 Feb 2015 in reply to Tom Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Georgi
    Admin
    Georgi avatar
    347 posts

    Posted 16 Feb 2015 Link to this post

    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.

     
Back to Top