question

ChrisB avatar image
ChrisB asked ChrisB posted

Attributes in Swing.snapshot output

Good morning,

 

When a snapshot command is done in a Swing session XML is returned representing the full hierarchy of components in the AUT. There are attributes in those elements for some of the component properties. For example:

 

<label className="javax.swing.JLabel"/>

 

Another attribute that comes through is name, if a component name has been set via the setName() method.

 

QUESTION: What is the list of properties that will come through as XML attributes? We've got className, name, and what else? This is for customer Pillar Data Systems specifically, but really for anyone doing Swing testing.

 

Thanks,

Chris

iTestGUI Testing(Web-Java Swing-etc)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PreetS avatar image
PreetS answered PreetS posted

The attributes that appear in the snapshot are the attributes we think could be used to identify a particular control. They vary based on the type of control, and if they are defined in the application. 

For labels, you do not see the value of the label because, the most common thing you'd want to do with a label is to get it's text. So if you identify a label by it's text to get it's text.. that would make no sense. 

 

You can, however, override the list of attributes that appear in the snapshot by implementing iTestable

4 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ChrisB avatar image ChrisB commented ·

ITestable is an option, and we'll use it if we need to. However, it will be lighter-weight to just use an attribute that we know is going to be included. Can you provide some examples for some of the common component types?

0 Likes 0 ·
PreetS avatar image PreetS ChrisB commented ·

The best option to use is the "name" property. Names act like IDs for swing application. 

When in question, add a name

 

However, here is some attributes that would generally show up. This is not the complete list, but the most common ones:

 

* All controls have name. This is has the highest priority and should be used when you can

* Most controls may have label, if iTest can associate a label with that control; e.g a label "first name" next to a text box

* Tooltip text appears for most controls as an attribute

* Image src for buttons that have images and no text

* Content Type and URL for Swing editor panes if they are valid

* Text for all sorts of buttons and controls that extend from buttons

* Text of popup menus

* Text for tooltip controls

* Title of frames 

* Title and modality of windows and dialogs

 

0 Likes 0 ·
tlawall avatar image tlawall PreetS commented ·

 


* Most controls may have label, if iTest can associate a label with that control; e.g a label "first name" next to a text box

* Tooltip text appears for most controls as an attribute

* Image src for buttons that have images and no text

* Content Type and URL for Swing editor panes if they are valid

* Text for all sorts of buttons and controls that extend from buttons

* Text of popup menus

* Text for tooltip controls

* Title of frames 

* Title and modality of windows and dialogs

 


Preet, do all of these items actually show up as XML attributes in the tags, so that they are selectable in the tree with Xpath, or are they properties that I'd have to use queries with "property()" on a describe response?

 

0 Likes 0 ·
PreetS avatar image PreetS tlawall commented ·

These are the attributes that show up in the XML (if they are valid and present for those controls)

 

The describe property set is a much much larger set of properties that is not present in the XML

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.