在 QTP 中测试飞出菜单
我正在寻找使用 QTP 触发弹出菜单操作的想法。
我正在使用 QTP 测试 Web 应用程序。该应用程序具有“级联”或分层弹出菜单。
例如 Options->Preferences
在重新编码时,QTP 会识别菜单层次结构上的终点(例如“Preferences”)。 但是在运行测试时,触发 WebElement("Preferences").Click
不起作用。
如果我调用 Link("Options").FireEvent ("onmouseover") 它会拉下菜单,之后我可以突出显示首选项项目,但即使在拉下菜单后调用单击也会失败触发菜单操作。
任何触发这些菜单项上的单击操作的想法都会很有用。
问候,
阿达沙
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果
Click
没有完成这项工作,那么可能存在 Web 应用程序期望的其他事件,但 QTP 没有模拟这些事件。解决此问题的一种方法是打开 Web 的 Device Replay 模式:在测试中的此行之后,每当 QTP 看到
Click
步骤时,它将通过将鼠标移到上方来重播它元素并模拟单击,因此所有由人类触发的事件都将被触发。要返回默认事件重播模式,请将“ReplayType”设置为 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: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.由于QTP执行时失去多任务处理的原因,我没有按照Motti的建议来实现。因此,我最终浏览了 HTML 代码,看看 java 脚本需要哪些鼠标事件。事实证明,我需要调用以下序列:
这个技巧确实很好用,但这里的风险是,如果他们彻底改变任何东西(比如,如果他们使用 onMouseDown,则将 Litening 改为 Click),我需要调整测试脚本。
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:
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.
我还有一个选择。使用它来单击任何对象。
I have one more option. use this to click on any object.
这是我对类似问题所做的处理:
不过,它可能不适用于更动态的 Javascript 菜单。
Here's what I did with a similar problem:
It might not work with a more dynamic Javascript menu, though.
我遇到了类似的情况,但处理方式略有不同,首先单击父链接
Options
,然后在序号标识符的帮助下触发 fireevent
onclick
,例如: browser( ).page().link(options).clickbrowser().page().link("name:=preferences","html tag:=A","index:=X" ).firevent "onclick"
这将理想地加载预期的父链接和将有助于点击时触发火灾事件 - 希望这有帮助。
I had a similar situation handled in slightly different manner, first click on the parent link
Options
then trigger the fireeventonclick
with the help of ordinal identifiereg: 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.