Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
How to select an item from context menu
posted

I have a right clicked context menu. QTP is able to record following steps:

Step 1: SwfWindow("Workspace 01 - ProfitTaker").SwfObject("indicatorExplorerBar").SelectItem "Basic","Predicted Low"
Step 2: SwfWindow("Workspace 01 - ProfitTaker").SwfObject("indicatorExplorerBar").ItemContextMenu "Basic","Predicted Low"

Step 1 makes QTP to select an item in the indicator panel. Step 2 makes it to right click on that particular item. after this step, I will see a contextMenuStip that has three items it it - Remove, Delete and Properties. I have to click on this Properties to see Properties window of "Predicted Low". but QTP is not recording this click and is not selecting Properties. Clicking on this Properties is very much required to continue my test. When I recorded very first time, QTP recorded this step as:

SwfWindow("Workspace 01 - ProfitTaker").SwfToolbar("contextMenuStrip1").Select "Properties..."

but second time it has not even recording this line. I executed above step but to my surprise, it is not able to run the same step that it has recorded. I am surprised why QTP is able to record this for the first time and why not for the next subsequent recording. 

  • 1040
    Suggested Answer
    posted

    I'm not sure if this is the same situation as you're dealing with, but we've had instances when we had to do some descriptive programming to get QTP to interact with the controls the way we wanted.

    For example, when we wanted to right-click on an ultragrid and select an option from the Context Menu, we had to use the SendKeys method so that QTP would "press" the Down Arrow key the desired number of times to select the option we wanted. Here's an example:

    Dim WshShell
    SwfWindow("Company").SwfWindow("Report").SwfTable("ultraGrid1").RightClick "2","0;ItemSize"
    set WshShell = CreateObject("WScript.Shell")
    WshShell.SendKeys "{DOWN}"
    WshShell.SendKeys "{DOWN}"
    WshShell.SendKeys "{DOWN}"
    WshShell.SendKeys "{ENTER}"
    SwfWindow("Item Summary").SwfWindow("SwfWindow").SwfToolbar("SwfToolbar").Select "Restore Default Layout"

    We're using TestAdvantage 2006 Volume 2 CLR 1.x and were eventually able to install a Hotfix from Infragistics that allowed us to perform the right-click without using the SendKeys method:SwfWindow("Item Summary").SwfTable("ultraGrid1").RightClick "2","0;ItemSize"
    Wait 1
    SwfWindow("Item Summary").SwfWindow("SwfWindow").SwfToolbar("SwfToolbar").Select "Restore Default Layout"

     

    We never had an instance when we needed to select a level beyond the first level of the Context Menu, but we did find that it was necessary at times to add a Wait statement between the "Right-Click" and the "Select" to give the Context Menu time to expand and make the desired selection.

    I hope this helps in some way. Let me know if you need further explaination.