I have not, but*, that won't stop me from giving you advice on how to do it. ;-)
There are two approaches, one easy+bad, the other hard+good.
The easy+bad way:
First, you use webdriver to open the browser and load the page that
contains your flash app.
Second, you maximize the browser window so the flash application is in
a precise predictable location on the screen.
Third, you use something like Java's Robot library to send an OS-level
clicking and typing to an absolute screen coordinate that lines up
with the fields and buttons in your flash app.
This is bad approach because testing using absolute screen coordinates
is very, very brittle, but sometimes it's better than nothing. You
might be able to improve this technique by using absolute screen
coordinates *relative* to the top/left corner of the browser window,
whereever it happens to be on the screen. But it's still a risky move.
Test automation depending solely on screen coordinates was how it was
done in the Dark Ages. It is an uncivilized and barbaric practice that
should only be seen in museums.
The hard+good way:
First, you modify the source code of you the flash application,
exposing internal methods using the ActionScript's ExternalInterface
API. Once exposed, these methods will be callable by JavaScript in the
browser.
Second, now that JavaScript can call internal methods in your flash
app, you use WebDriver to make a JavaScript call in the web page,
which will then call into your flash app.
This technique is explained further in the docs of the flash-selenium
project. (http://code.google.com/p/flash-selenium/), but the idea
behind the technique applies just as well to WebDriver.
Basically, there is no free lunch when it comes to testing a flash app
inside the browser. You either have to do it the bad old way using
brittle absolute screen coordinates, or you have to extend/modify your
flash application with custom automation methods. This is not a
possible solution if you don't have full control over the flash app's
source code. But if you do have full control, using the
ExternalInterface API is the preferred way to go.
- Jason Huggins
twitter: @jhuggins
flashselenium-java-client-extension-1.0.jar |
|