Testing Fly Out Menu in QTP

北城余情 提交于 2019-11-26 20:50:19

问题


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


回答1:


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.




回答2:


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.




回答3:


I have one more option. use this to click on any object.

Set objMenu = Browser("Browser").Page("Pagel").WebElement("Menu_ELM")
Set objDeviceReplay1 = CreateObject("mercury.devicereplay")
x = objMenu.GetROProperty("abs_x")
y = objMenu.GetROProperty("abs_y")
objDeviceReplay1.MouseClick x + 35 , y + 5,0
Set objDeviceReplay1 = Nothing



回答4:


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.




回答5:


I had a similar situation handled in slightly different manner, first click on the parent link Options then trigger the fireevent onclick with the help of ordinal identifier

eg: browser().page().link(options).click

browser().page().link("name:=preferences","html tag:=A","index:=X").firevent "onclick"

This would ideally load the intended parent link & would be helpful in triggering fire event on click- Hope this helps.



来源:https://stackoverflow.com/questions/1455212/testing-fly-out-menu-in-qtp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!