Question

I'm trying to set up UI automation for Silverlight 3. I have a little test project that has 2 elements, a Button and a TextBlock. When you click the button the text is supposed to change.

I have been able to simulate a button click and the text does correctly change on the UI. However I am having problems retrieving the text from the TextBlock. UISpy shows that it is of type "text" but it also shows that it implements no control patterns. If I use a TextBox I can get the text correctly using a ValuePattern, but I would prefer to use TextBlock.

Does anyone know how to get the current text of a TextBlock from it's AutomationElement object?

Was it helpful?

Solution

TextBlock exposes its text as the Name property of the automation element, so you can read the text from myTextBlockAutomationElement.Current.Name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top