question

JeffJ avatar image
JeffJ asked JeffJ posted

How to configure a test case to sort a table in Java?

I have a customer that is trying to build a test case for a Java Swing application.  In the test case, there is a table of information that needs to be sorted based on one of the columns.  The entire header row is in one object.  In the normal case (without iTT), you can left mouse click on the column you want to sort on and the table will sort accordingly.  How can this be accomplished using iTest?
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

There is a swing action called "clickColumnHeader". This capability appears when you have selected a table in the component tree. 

You can specify what column header you want to click on based on the column name or the column index. 

When you invoke this action, the mouse clicks at the center of the header.  

 

 

 

If you want to click somewhere else on the header, and not in the center, then read below: 

 

 

  • Use 'describeColumnHeader' to get the height and width of the header (lets call them H and W)
  • Use MouseMove capability to move the mouse where you want to click. Select location to be relative to the control. Which will move the mouse to the X and Y coordinates with the top left corner of the control as a reference. (e.g. if you want to move your mouse to 1/3 of the way, X would be W/3 and Y would be H/2)
  • Now invoke the 'Click' capability and select 'do not move the mouse' because your mouse is already there where it needs to be. 
 
Having done this, you have clicked on very specific customized coordinates. Note that these steps will be captured, but may not execute as desired in 'interactive' mode. When rendered to a test and then replayed, it will work fine. 

 

10 |950

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

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.