How can SilkTest click a column header on a JFCTable ?
Although SilkTest does have a built in ClickCol() method this does not always seem to work. There is an alternative, using some of the Native methods of the JDK.
- You must expose the JTableHeader control. This can be done by adding the following to your JavaEX.ini under the " [ClassList]" section ;
- You must then add the following winclass to your declarations ;
[-] winclass JTableHeader : Control [ ] tag "[javax.swing.table.JTableHeader]" [ ] [ ] obj RECT getHeaderRect (int i1) [ ]
This will expose the getHeaderRect () method within the JTableHeader Control.
- Next you will need to change the customwin declaration for the JTableHeader object so that it reads something along the lines of ;
[-] JTableHeader TheTable2 [-] msw multitag "[javax.swing.table.JTableHeader]The Table" [ ] "[javax.swing.table.JTableHeader]$javax.swing.table.JTableHeader"
- When this is done you can implement the following function that takes the number of the column header you want to click as a parameter. This could be modified to accept the heading if you wished ;
[-] ClickHeader(int i ) [ ] [ ] // Get The width of a Column Header [ ] RECT rTable = xTable.TheTable2.getHeaderRect(1) [ ] // Get the total number of Columns in the table [ ] int iColCount = xTable.TheTable1.GetColumnCount() [ ] [ ] // Move to the appropriate point by multiplying the number of columns across [ ] // you wish to move by the width and then subtracting half the width of a column. [ ] xTable.TheTable2.MoveMouse((rTable.xSize*i)-(rTable.xSize/2),rTable.ySize/2) [ ] xTable.TheTable2.Click() [ ]
Old KB# 22223