How to record right click of a context menu and click on the
selection ?

Answers were Sorted based on User's Feedback



How to record right click of a context menu and click on the selection ?..

Answer / amarendra kothuru

We cannot record the right click operation. But we can
achieve this by using below script.

Set menu=browser("MSN.com").Page("MSN.com").Image("F430 (©
Ferrari S.p.A.)")
idx=3 '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 3
For i = 1 To idx-1
WshShell.sendkeys "{DOWN}"
Next
WshShell.sendkeys "{ENTER}"
Set WshSEll = nothing
Set obj = nothing

Is This Answer Correct ?    3 Yes 0 No

How to record right click of a context menu and click on the selection ?..

Answer / amarendra kothuru

Hey Promod,

The way the question was asked and what you were providing
was wrong. The Answer you provided may or may not work on
all applications which generates Context menu. Your code may
work on Windows based objects and usage of "WinObject" test
object is not suggestible every time. Don;t think that QTP
always treat Context menu as WinListView or WinMenu.

But if you handle it with the code what i provided, there is
high probability to work with context menu. But your
application must be the active page at the time of
execution. Otherwise it wont perform correctly. There would
be drawbacks on each option.

Regards
Amarendra Kothuru

Is This Answer Correct ?    2 Yes 1 No

How to record right click of a context menu and click on the selection ?..

Answer / pramod k sirotia

Very Wrong Amarendra Kothuru
why r u taking such Complicated way.

Well First of all, i am not clear which Context menu you
are talking about, whethere is it Desktop Context menu or
menu for those object those are running on System tray as
notification Area.
BTW, 1)
If you record right click on Context menu for Deskop it
will generate script as below:
Window("Program Manager").WinListView
("SysListView32").Click 1199, 286, micRightBtn
Window("Program Manager").WinObject
("SHELLDLL_DefView").WinMenu
("ContextMenu").Select "Refresh;"

While you are running this Scirpt only one Run Error you
may be getting that is "Object is not visible" which is due
to your QTP Screen may be overlaaping of your perform
action. So please make sure while running these kind of
test, QTP should not be overlapping.

Else your test will be running fine and will show up you
result as per your action.
2) The 2nd thing is the right clik on the object over
Notification area, So i would recommed you to first hide
all those object by system property and record only object
that click you want to record, becuase those are dynamic
objects and therir postion might be change while running
the test.

Hope this will help you to get problem out

Thank you very much!

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More QTP Interview Questions

What is the meaning Work bench?

0 Answers  


What is the difference between wait and synchronization point?

3 Answers  


How to pass parameters into an action.Please explain me with examples

5 Answers  


How to create runtime property for an object?

7 Answers  


WHAT IS ENVIRONMENT VARIABLES?

7 Answers   AZTEC, CTS, Ready Test Go,






How to connect the real time application application with the QTP?

2 Answers  


write script to read and write data from file ?

2 Answers   HealthAsyst,


Problem with XML checkpoint in QTP ?

0 Answers  


assume i have few url link how will i dynamically call then using descriptive programming?

0 Answers   BirlaSoft,


How to release all resources file from the QTP?

0 Answers   Tech Mahindra,


what is compiled module?

1 Answers  


Hi I am new to QTP. we are planning to implement automation for the application. I am trying to execute the following script: Set ExcelObj=CreateObject ("Excel.Application") ExcelObj.WorkBooks.Add Set NewSheet=ExcelObj.Sheets.Item(1) NewSheet.Name="Order" ExcelObj.Cells(1, 1).Value = "Name" ExcelObj.Cells(1, 2).Value = "Ordernum" ExcelObj.Cells(2, 1).Value = "nam" ExcelObj.Cells(2, 2).Value = "21" ExcelObj.ActiveWorkbook.SaveAs "c:\test1.xls" ExcelObj.Quit Set ExcelObj = Nothing in the above script for the line(ExcelObj.Cells(2, 2).Value = "21") it is inserting the value 21 successfully.this is fine But if i want to insert a variable instead of the constant value then what should be the modification in the script. For example: If user retrives a value throug "GetRoProperty" and wants to insert the value into then how the script changes?

1 Answers  


Categories