This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Testing and the fly likes Locating components with Jemmy... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Locating components with Jemmy..." Watch "Locating components with Jemmy..." New topic
Author

Locating components with Jemmy...

Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
I'm returning to Java after many years away; I'm generally a web application programmer in various scripting languages, so returning to stand-alone GUI apps in Java is slow going. I try to follow TDD in whatever language I'm working in.

I'm having trouble locating components with Jemmy. Their on-line API documention appears to no longer be linked for netbeans site, nor are the classes listed in the master list. However some google search's turned up some possibly orphaned pages. The book I've been working from references a "NameBasedChooser" for locating components when you have multiple similar type compoents (such as 3 JLists). However, there doesn't seem to be any "NameBasedChooser" class in the Jemmy package at this time. I found a NameComponentChooser but it doesn't seem to work.

The text based chooser fails because the first JList tends to contain superstrings of all the possible search terms in the later JLists.

Can anyone offer advice? or links to more complete Jemmy tutorials than at the jemmy.netbeans.org site? Thank you.

Eric
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you explain more about why the NameComponentChooser doesn't work for you?

If I remember correctly, it's doing something like the following:


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
Looks like it was just an oversight on my part -- the first JList that Jemmy kept claiming for any of the latter ones was wrapped in a JScrollPane. I had named the JScrollPane not the wrapped JList, so of course the NameComponentChooser argument on the JListOperator wasn't finding anything.
Daniel Hinton
Greenhorn

Joined: Aug 13, 2011
Posts: 2
I'm having a similar problem (I believe).

I have a button labeled "Continue" but there is text above it that instructs a user to click "Continue" I feel like my clickContinue() is clicking on the text instead of the button:

public SomeArbitraryPage clickContinue() {
JLabelOperator alternateContinueButton = new JLabelOperator(appFrame, "Continue");
alternateContinueButton.waitComponentShowing(true);
alternateContinueButton.clickMouse();
return new SomeArbitraryPage(sessionObject);
}

The unit tests where I lead up to clicking this, as well as the actual clicking test pass. How would one make it so that I either loop through and click both... or just click the second one it finds?

Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Locating components with Jemmy...
 
Similar Threads
Feedback Abbot's use
Can you load Java Swing Gui code through a JSP page?
Jemmy Closing Application
JOptionPane and Jemmy
Optimizing my Swing app