Hi all,
we are evaluating JFCUnit for the first time. It seems that buttons in an application can be only found by the Finder classes via their name (button.setText()) or their icon (button.setIcon()).
What if we have several buttons on the screen all having the same text on it ("...") or having the same icon (e.g. a trash can). Is there another way to identify a unique button ?
Could specifying the index of the component inside the container bring a solution ? What exactly does the index mean to JFCUnit ?
Thanx a lot for any hints on that.
Regards,
Stefan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If all other things are equal, (same text, same parent container, etc.) then there is no other way to distinguish the buttons other than using one of the find methods with an index or a findAll method to return all the components meeting your search criteria.
I believe the components are indexed in the order that they were added to the parent container (Can anyone confirm this?).
Sometimes I find using the included browser application helpful in determining other ways to search for component. Start junit.extensions.jfcunit.tools.ComponentBrowser alongside your application to view component properties. Sometimes specifying the class type or the container it is placed within can help narrow the search.
Regards,
B.Modi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You may also want to perform a find on a label and then navigate up to the container. Then search within the container for the single button. If this makes sence in your GUI.
You could also extend the button finder to use the AccessibleText, as this may also be unique.
There are several ways you could accomplish this, however, most things would be dependent on navigating your specific component Hierarchy.
Cheers, Kevin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And what about the "matchPattern" method of the Finder class and subclasses?
"protected final boolean matchPattern(java.lang.String componentAttribute,
java.lang.String patternString,
org.apache.regexp.RE re)
This method is used to filter components' attributes based on a pattern specified by the user. For example, to search for all windows with title matching 'testWindow*'. Note: If the patternString is null, we need to avoid the PatternCompiler.compile() throwing a NullPointerException and in this case, return true if the componentAttribute is also null. The pattern syntax can be found at the Jakarta RegExp API Documentation in RE.
Parameters:
componentAttribute - The attribute text of the component to match against
patternString - The pattern to match with
re - The RE pattern matcher to be used
Returns:
boolean whether the pattern is contained within the components' attribute text "
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
we are evaluating JFCUnit for the first time. It seems that buttons in an application can be only found by the Finder classes via their name (button.setText()) or their icon (button.setIcon()).
What if we have several buttons on the screen all having the same text on it ("...") or having the same icon (e.g. a trash can). Is there another way to identify a unique button ?
Could specifying the index of the component inside the container bring a solution ? What exactly does the index mean to JFCUnit ?
Thanx a lot for any hints on that.
Regards,
Stefan
Stefan,
If all other things are equal, (same text, same parent container, etc.) then there is no other way to distinguish the buttons other than using one of the find methods with an index or a findAll method to return all the components meeting your search criteria.
I believe the components are indexed in the order that they were added to the parent container (Can anyone confirm this?).
Sometimes I find using the included browser application helpful in determining other ways to search for component. Start junit.extensions.jfcunit.tools.ComponentBrowser alongside your application to view component properties. Sometimes specifying the class type or the container it is placed within can help narrow the search.
Regards,
B.Modi
You may also want to perform a find on a label and then navigate up to the container. Then search within the container for the single button. If this makes sence in your GUI.
You could also extend the button finder to use the AccessibleText, as this may also be unique.
There are several ways you could accomplish this, however, most things would be dependent on navigating your specific component Hierarchy.
Cheers, Kevin
you can also search using the name of the button (JButton.setName()) at least that is how i did it. hope this helps
And what about the "matchPattern" method of the Finder class and subclasses?
"protected final boolean matchPattern(java.lang.String componentAttribute,
java.lang.String patternString,
org.apache.regexp.RE re)
This method is used to filter components' attributes based on a pattern specified by the user. For example, to search for all windows with title matching 'testWindow*'. Note: If the patternString is null, we need to avoid the PatternCompiler.compile() throwing a NullPointerException and in this case, return true if the componentAttribute is also null. The pattern syntax can be found at the Jakarta RegExp API Documentation in RE.
Parameters:
componentAttribute - The attribute text of the component to match against
patternString - The pattern to match with
re - The RE pattern matcher to be used
Returns:
boolean whether the pattern is contained within the components' attribute text "