Access cell's validation state through UI automation

4 posts, 0 answers
  1. Arthur
    Arthur avatar
    22 posts
    Member since:
    Jul 2014

    Posted 30 Apr 2015 Link to this post

    Hi,

    I am currently trying to get some access to the validation state inside a cell through UI automation.

    What is set when a validation error occurs is GridViewEditorPresenter.ErrorMessage. I thought, I could bind for example AutomationProperties.ItemStatus of the presenter to this message but unfortunately the GridViewEditorPresenter does not provide an AutomationPeer, so it is not visible to UI automation tools. Then I though about adding a peered element parallel to the presenter, but GetChildrenCore() of the parent cell does not deliver other thing than the presenter's content.

    So my question ist: How to access the validation error message through UI automation?

    Thanks,

    Arthur

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1216 posts

    Posted 05 May 2015 Link to this post

    Hello,

    Please excuse me for the delayed reply. Generally, we use ItemsStatus as an intermediate property that contains the serialized values of the automated controls' properties. Then these values are and used in our CodedUI extensions. However, if you are not using the extension dll, the itemsstatus would be meaningless, as it would represent a sequence of values.
    I am afraid that currently GridView celI only exposes its validation status (valid or not) through the automation API (not the invalid message itself). If you need property assertion in a CodedUI test, you can try the extensions and assert GridViewCell's IsValid property. However, if you already have some written tests, migrating them with the extension would be difficult. The other (quick and dirty) option is to access the GridViewCell's automation peer and read the itemsstatus string. IsValid should be the eight value.

    Regards,
    Ivan Ivanov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Arthur
    Arthur avatar
    22 posts
    Member since:
    Jul 2014

    Posted 11 May 2015 in reply to Ivan Ivanov Link to this post

    I have solved it differently:

    In our application, we do not use the default columns, but derive al columns from our own base column type.

    In CreateCellEditElement() override I just do the following now:

     

    Binding itemStatusBinding = new Binding("ErrorMessage");
     
    itemStatusBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(GridViewEditorPresenter), 1);
     
    editorElement.SetBinding(AutomationProperties.ItemStatusProperty, itemStatusBinding);

    So I use the the ItemStatus of the cell editor to publish the error message of the surrounding cell. This way the testers can see whether an non empty error message exists by reading out the ItemStatus on the editor element.

     

     

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 May 2015 Link to this post

    Hi,

    Thank you for sharing the solution you came up with to the community. 

    Regards,
    Dimitrina
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top