在 QTP 中测试飞出菜单

发布于 2024-08-04 21:36:40 字数 399 浏览 4 评论 0原文

我正在寻找使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

凹づ凸ル 2024-08-11 21:36:40

如果 Click 没有完成这项工作,那么可能存在 Web 应用程序期望的其他事件,但 QTP 没有模拟这些事件。解决此问题的一种方法是打开 Web 的 Device Replay 模式:

Setting.WebPackage("ReplayType") = 2 

在测试中的此行之后,每当 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:

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.

撩人痒 2024-08-11 21:36:40

由于QTP执行时失去多任务处理的原因,我没有按照Motti的建议来实现。因此,我最终浏览了 HTML 代码,看看 java 脚本需要哪些鼠标事件。事实证明,我需要调用以下序列:

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

这个技巧确实很好用,但这里的风险是,如果他们彻底改变任何东西(比如,如果他们使用 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:

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.

百善笑为先 2024-08-11 21:36:40

我还有一个选择。使用它来单击任何对象。

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

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
纵山崖 2024-08-11 21:36:40

这是我对类似问题所做的处理:

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

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

不过,它可能不适用于更动态的 Javascript 菜单。

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.

早乙女 2024-08-11 21:36:40

我遇到了类似的情况,但处理方式略有不同,首先单击父链接 Options,然后在序号标识符

的帮助下触发 fireevent onclick,例如: browser( ).page().link(options).click

browser().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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文