简体   繁体   中英

Right click operation on SwfTable column header in UFT

I am working on automating an application through UFT, in this process I need to search for specific text from a list of records in SwfTable.

This table has column headers, where on doing a right click on column header will let me to enter filter text.

My table looks like this

表格截图

Right click on column header will let me to enter filter text

过滤截图

Code snippet captured for table is

SwfWindow("XXX").SwfWindow("Dashboard").SwfTable("completedGrid").

I have searched in many forums but didn't find a solution, can someone help me here.

I had a similar issue when I was automating a web application. This was what I did:

Set menu=Browser("").Page("").WebElement("")
idx=2
'This var. points the which option to select in the right click menu. This var. is 
'always the option+1 value. Ex. If u want to select the second option then the var. 
'should have the value 3
Set obj = CreateObject("Mercury.DeviceReplay")
Set WshShell = CreateObject("WScript.Shell")
'Get the absolute coordinates of the ibject
absx = menu.QueryValue("abs_x")
absy = menu.QueryValue("abs_y")

obj.MouseClick absx, absy, 2
'Optional wait statement
wait 1

For i = 1 To idx-1
   WshShell.sendkeys "{DOWN}"
Next
WshShell.sendkeys "{ENTER}"
Set WshSEll = nothing
Set obj = nothing

If your AUT is a desktop application, just change your menu to the element where you want to right click. Hope it helps!

The Universal and Agnostic Solution would be: GetTextLocation . You call the method on the Table (maybe define the Search Rectangle as well), and the method will tell you the coordinates of a Rectangle where the Text is Found. This is mostly based on Text Recognition so it will be very unstable: Just forget it, rarely works :)

A better solution would be:

x = CINt(SwfTable("Table").GetCellProperty 0, "COLNAME", "x")  
y = CINt(SwfTable("Table").GetCellProperty 0, "COLNAME", "y")

These are the coodrinates of the Cell in the First Row in your Column. Now we just need to move to the center of the Header of this Column. That is simply just an other calculation

' Move Right
x = x + 20
' Move Up  
y = y - 20

This might work, but it's still very rough and can become easily unstable. With the same Method, You can get the height and width Property of the Cell and use that to calculate the Center of the Header:

x = x + (width / 2)
y = y - (height / 2)

Much Better, but implies that your header cell is having the same size as your Table Cells.

If this is not the case you have to use the Object methods and with some Reverse Engineering get a Reference to your Table Columns and do some calculation.

In Summary : It is about navigating between rectangles and basic geometry. You can get much more fancier and may not even need to use Object methods, just draw it and play with it.

Documentation for GetCellProperty

Almost forgot: When you have The Coordinates simply:

SwfTable.Click x, y

These are relative coordinates so you do not need to add them to abs_x and abs_y.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM