gettier wrote: > I am trying to get more information on use and capabilities of the Flex > Automation API. The Class and Interface info from the Language > Reference doesn't really show how to use the API.
There isn't much documentation right now, so until Adobe remedies this, you'll need to read the source and have at least some understanding of how the rest of the Flex framework is built to get going with Flex Automation. That's not to say that the documentation isn't helpful, it'll give you a good bird's eye overview of how everything is hooked together. I've been playing with it quite a bit since it came out and for the most part, discovered how to get it to work with my own code through reading the code and trial and error. To begin with, if you want to integrate into the whole framework, you should start with the Automation class and pass it the adapter class that'll be driving it. Minimally, this adapter class should implement the IAutomationManager and IAutomationObjectHelper interfaces. If you have the Mercury QTP plugin (requires a FDS license plus Mercury QTP), there should be an adapter already provided, though I don't know if Adobe provided the source code with that. If, however, you're like me and don't have all that good stuff lying around, you can write your own adapter class and direct the output somewhere more useful--you've several options--a compiled-in debug window, over LocalConnection like how XRay does things, or over a socket connection to an external harness program that you've written. The Automation class contains a map of registered component classes to their automation delegates in a static variable named delegateClassMap. This is located in the mx_internal namespace, so you'll have to declare you're using it to get access to it (at your own risk, as some of the Adobe engineers have publicly stated that mx_internal variables are subject to change between revisions and aren't a guaranteed interface). The standard Flex UI components and the charting classes have delegates already written. You'll need to provide delegate classes for each of your own custom components if you want to automate them (see the Flex 2.0.1 documentation for an example of how to write an automation delegate for Ely Greenfield's RandomWalk class). Once you've loaded all your delegates, you can then use your adapter and the delegateClassMap to locate and create an automation delegate instance mapping to each component instance that you want to automate. At this point, your delegate can report appropriate functional events for logging and/or recording for replay to your adapter via its recordAutomatableEvent method, and can replay events on the component passed to it by calling the replayAutomatableEvent method. If you don't care for the integrated framework aspect of things, you can also pursue a simpler approach of just including the necessary delegate implementation classes for your components and then creating instances of them referencing each of your components. While doing so doesn't hang together quite as well, it does allow you to fairly quickly script a single component or two if you need some basic automation for testing client side form validation and the like. That's the quick summary of how it all hangs together--there's a bunch of additional stuff like synchronization and identifier mangling that I haven't yet had enough time to figure out yet, but this should be enough to get you started making good use of the automation framework. Jim Cheng effectiveUI

