

Recording (And Playback) Of User Actions In Java? 8
mnalsky asks: "I need an automated system for Java applications testing. I'd like the system to be able to record user session of Swing application and dump it to a file. Then one can play back this file and the application will repeat all of the steps. I've searched through the Web for it and have found nothing. Sun had its tool JavaStar, but in November, 1999 they stopped developing it. Now it's not possible to download JavaStar from their Web site, and I can't find it anywhere else on the Web. Are there any other tools like this? Is JavaStar available somewhere that I might have missed?"
Take a look at XD/Replay (Score:1)
Look at Mercury Interactive's products (Score:1)
NOTE: I'm writing this on a computer owned by Mercury Interactive.
Mercury (http://www.merc-int.com) has two products that may help you - WinRunner and XRunner. They are commercial only, and I don't know of free demos available. You get a powerful C-like scripting language and a complete IDE for recording, debugging and replaying the scripts. If I say more, I'll be accused of advertising :-)
The more advanced, Windows only, product is WinRunner. It also supports native Windows apps, Deliphi, ActiveX, and probaly other stuff I haven't heard about. Last time I saw it, XRunner was a tiny bit behind on the user-friendly side. It's basically Unix version of WinRunner, (only Solaris, HPUX and AIX - no Linux, but if you show interest, they just might go ahea and do it). Supports Java, Motif and Ilog.
I don't know about pricing of these products, so I can't help you decide if it's on you're budget. You'll have to contact Mercury to see about that.Re:java.awt.Component.dispatchEvent (Score:1)
In the 1.3 API (Score:1)
This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.
Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.
Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. For example, X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.
So basically you can create a test class with an instance of Robot and give it all the commands you need to do. It will mimic keyboard and mouse input, and will also perform screen captures if you want. I wish they had this for my last project using 1.2. It would have made life a lot easier.
My take on this: (Score:1)
Java macros: GOOD! Think of what we could do with this.
Java user tracking: BAD! Your actions are already bogged down by that damned JavaScript; now it's tracking your every nuance and move? UGHHHH!!!!
Pretty simply theoretically, but probably a pain.. (Score:1)
1. keyboard presses
2. mouse moving
3. mouse clicking
all of which are handled by actionListeners (forgive me if my terminology is off, i haven't coded java in a year or so)...so, you keep some sort of vector type thing that holds a list of actions the user has performed. whenever one of the above events occurs, all you need to do is create an entry with the coordinates/key/whatever, and you have your record.
the only thing you might wanna do is rather than recording a button press as simply "MOUSE_RIGHT_DOWN at 230,230", actually indicating a button directly would speed it up a bit...although it'd make for slightly harder parsing in playback.
dunno, doesn't seem like too huge a thing to me, although i can't say much for how efficient it'd be...
java.awt.Component.dispatchEvent (Score:2)
When you want to play back the user's actions, disable logging, and then call dispatchEvent() with each of the deserialized events. That should give you a play-by-play exact copy of everything the user did (including moving the mouse...)
This won't work if you have multiple windows unless you're creative... so be creative with it.
Standard disclaimer that this doesn't represent professional advice and I've never tried it, but it might work...
(Also, an AC mentioned java.awt.RobotThis class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.) [sun.com]
Re:Pretty simply theoretically, but probably a pai (Score:2)
I HIGHLY recommend checking out the FAQ for the usenet group: comp.software.testing . It can be found at: http://www.faqs.org/faqs/soft war e-eng/testing-faq/ [faqs.org] or at: http://www.cigital.com/c.s.t.faq.html [cigital.com]
There's MUCH MORE to automated testing that just recording and playing back keyboard/mouse input.
Here are some of the issues that need to be dealt with:
I could go on and on, but this hopefully gives a hint to the complexity and difficulty in automated testing. (And, yes, I've stumbled upon ALL of these myself at one time or another.)