tags:

views:

710

answers:

4

Hi, I am looking for ideas to trigger the actions for fly-out menus using QTP.

I am testing a Web App using QTP. The application has "cascaded" or hierarchical fly-out menu.

e.g. Options->Preferences

While recoding QTP recognizes the end point on the Menu hierarchy (say "Preferences"). But while running the test, firing the WebElement("Preferences").Click does not work.

If I call Link("Options").FireEvent ("onmouseover") it pulls down the Menu, and after that I can highlight the Preferences item, but calling the click even after pulling down the menu fails to trigger the menu action.

Any Ideas to trigger the click action on these menu items would be useful.

Regards,
Adarsha

+3  A: 

If Click doesn't do the job then there are probably other events that the web app is expecting that are not simulated by QTP. One way to work around this is to turn on Web's Device Replay mode:

Setting.WebPackage("ReplayType") = 2

After this line in the test whenever QTP sees a Click step it will replay it by moving the mouse over the element and simulating a click so all the events that are fired by human beings will be fired.

To go back to the default event replay mode set "ReplayType" to 1.

Motti
By setting the Device Reply mode to reply mouse actions, you will loose the ability to work on other things when QTP is executing. I have dual monitor and usually let the QTP running in secondary monitor while working on other things.But its a nice littel trick to consider.
Adarsha
Have you tried working with QTP in a virtual machine? That way using device replay won't steal your mouse.
Motti
Does this also mean that if the button isn't visible on the screen because it's below the fold (ie: you need to scroll to see it), QTP will find it?
Riddari
@Riddari, if the button isn't visible on your physical screen but is visible in the virtual display (i.e. if you scroll the RDP window it will be visible) then it will work. I've verified this on Microsoft's mstsc.exe).
Motti
+1  A: 

For the reason of loosing multitasking while QTP is executing, I did not implement with Motti's suggesiton. So instaed I ended up going through the HTML code to see which mouse events are expected by the java script. It turns out i need to call the below sequences:

Link("Options").FireEvent ("onmouseover")
WebElement("Preferences").FireEvent ("onmouseover")
WebElement("Preferences").FireEvent ("onClick")

This trick works really nice, but the risk here is if they change any thing drastically (say instaed of litening to Click if they use onMouseDown) I need to tweak the test script.

Adarsha
You may consider creating custom support for this menu using Web Extensibility (that way you can parametrize on the menu item).
Motti
A: 

Please visit the link below to know how to work with Events...

Work With Fire Events

animesh
A: 

Here's what I did with a similar problem:

Set desPrefLink = Description.Create
    desPrefLink("micclass").value = "Link"
    desPrefLink("innertext").value = "Preferences"

Browser(X).Page(Y).Link(desPrefLink).Click()

It might not work with a more dynamic Javascript menu, though.

Riddari
Exactly.. In my case desPrefLink is not visible to QTP until the onmouseover event is fired on Options link.
Adarsha