O'Reilly logo

Swing Extreme Testing by Tim Lavers, Lindsay Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Cyborg—a Better Robot

Over the next seven chapters, we will be concentrating on techniques for testing user interfaces. Our most basic tool for this is Cyborg.

The java.awt.Robot class, introduced in JDK 1.3, allows us to generate native mouse and keyboard events in our test programs. This makes it possible for us to write automated tests for user interfaces.

Now, Robot is a low-level class, having methods such as keyPress(int keycode) and mouseMove(int x, int y). In our tests, by contrast, we want to type long strings of text, click elements of lists, close windows, activate menus with mnemonics and accelerators, and do myriad other things. To bridge the gap, we have developed a wrapper class called Cyborg, which has convenience ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required