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

Access cell's validation state through UI automation

3 Answers 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arthur
Top achievements
Rank 1
Arthur asked on 30 Apr 2015, 03:21 PM

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

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 05 May 2015, 02:36 PM
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.

 
0
Arthur
Top achievements
Rank 1
answered on 11 May 2015, 12:41 PM

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.

 

 

0
Dimitrina
Telerik team
answered on 11 May 2015, 12:49 PM
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.

 
Tags
GridView
Asked by
Arthur
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Arthur
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or