Mariya Selvam
Mariya Selvam

Reputation: 9

How to get x,y coordinates for text area check point in QTP?

While recording in qtp using a text area check point to select some area. After recording and playback save the test cases. Now I want to know the x and y coordinates for the selected area. Is it possible to see the x and y values in result.xml or somewhere in saved test case?

Upvotes: 1

Views: 7939

Answers (1)

AutomatedChaos
AutomatedChaos

Reputation: 7490

I do not exactly understand what you want. Maybe you can explain more in detail. For the time being, I give you some information you can use:

If you want the absolute coordinates of an object, use:

absX = myObj.GetRoProperty("abs_x")
absY = myObj.GetRoProperty("abs_y")

For the coordinates of an object relative to its parent, use:

relX = myObj.GetRoProperty("x")
relY = myObj.GetRoProperty("y")

To get the relative coordinates of the checkpoint of the text area, use:

cpRelX1 = CheckPoint("text area checkpoint").GetProperty("text_area_x1")
cpRelX2 = CheckPoint("text area checkpoint").GetProperty("text_area_x2")
cpRelY1 = CheckPoint("text area checkpoint").GetProperty("text_area_y1")
cpRelY2 = CheckPoint("text area checkpoint").GetProperty("text_area_y2")

If you want to have the absolute location of the CheckPoint during playback, you need to sum the absolute coordinates of the text area and the relative coordinates of the checkpoint:

'  upperleft corner:
realCheckPointXduringRuntime = absX + cpRelX1
realCheckPointYduringRuntime = absY + cpRelY1

For the lowerright etc., you just can combine the coordinates:

'  lowerright corner:
lrX = absX + cpRelX2
lrY = absY + cpRelY2

'  lowerleft corner:
llX = absX + cpRelX1
llY = absY + cpRelY2

'  upperright corner:
urX = absX + cpRelX2
urY = absY + cpRelY1

Upvotes: 1

Related Questions