Testing Fly Out Menu in QTP

北城余情 提交于 2019-11-27 21:44:53

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.

Adarsha

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.

nadeemsharif

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

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.

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.

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