Friday, February 19, 2010

How to access a test object's AutomationPatterns

If your business is automating WPF applications you should know all about UI Automation Control Patterns. If you do and you wish you could access some automation pattern properties on your TO's, there's a very convenient way: you can access an automation pattern either by name or by index. for example:
WpfWindow("window").WpfListView("list").AutomationPattern("Selection").GetSelection()
will return an AutomationElement that is the current selection in the list.
I found this extremely useful when tackling text containers. The following call returns text from a TextBox, Label or any other TextPattern implementor:
WpfWindow("window").WpfEdit("textBox1").AutomationPattern("Text").DocumentRange.GetText(-1)

Next up: using a similiar technique to retrieve values from a wpf grid !

1 comments:

amit said...

Hi Friends

my query is How to retrieve child objects from a WPFGrid control in qtp. when spying, qtp is identifing only the WPFGrid and note the objects inside it. pls suggest workaround for this

can you pls send me some example to use Automation pattern

WpfWindow("title").WpfTable("title").AutomationPattern......


Inside the wpftable there are four columns and some rows. first column contains chechboxes. i want to check/uncheck that. anything inside the wpftable are not recognized by object spy

Post a Comment