IE Automation有所不同 [英] IE Automation with a twist

查看:125
本文介绍了IE Automation有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个IE扩展程序,我想通过自动化对其进行测试.该扩展程序将一个项目添加到Internet Explorer的上下文菜单.这是我需要能够自动化的步骤:

1.导航到特定网页(这很容易)
2.在该页面上查找并突出显示一段文本. (这很容易)
3.打开上下文菜单(就像用户发出了右键单击一样)
4.在上下文菜单中选择一个特定的项目.

有许多方法可以实现前两个步骤.我可以使用WebBrowser控件来做到这一点,使用Leslie Hanks 自动化Internet Explorer 所述的IEDriver,等等.这些方法均不允许访问上下文菜单.我可以从AxSHDocVw.AxWebBrowser重载ShowContextMenu方法并显示我自己的上下文菜单,但这不是重点.我需要锻炼现有的上下文菜单.

我不了解的一件事是,如果我创建一个WebBrowser对象并导航到页面,则即使页面显示得很好,我也可以右键单击控件,但WebBrowser.ContextMenu始终为null.并查看默认的上下文菜单.

预先感谢您提供有关我做错事情的任何线索.

I have an IE extension which I want to test via automation. The extension adds an item to the Internet Explorer''s context menu. Here are the steps I need to be able to automate:

1. Navigate to a specific web page (this is easy)
2. Find and highlight a section of text on that page. (this is easy)
3. Open the context menu (as if the user issued a right-click)
4. Select a particular item in the context menu.

There are any number of ways to achieve the first two steps. I could do it with a WebBrowser control, use the IEDriver as described by Leslie HanksAutomate Internet Explorer, etc. None of these methods allow access to the context menu. I can overload the ShowContextMenu method from AxSHDocVw.AxWebBrowser and display my own context menu but that''s not the point. I need to exercise the existing context menu.

One thing (of many) that I don''t understand is that if I create a WebBrowser object and navigate to a page, the WebBrowser.ContextMenu is always null even though the page displays just fine and I can right-click in the control and see the default context menu.

Thanks in advance for any clues as to what I''m doing wrong.

推荐答案

我的解决方法是使用现有工具进行GUI测试自动化(因为我想要在用户级别而不是在实现的技术细节级别上实现自动化).
一个非常有用的是 Ranorex [ ^ ].
它是一个C#API,可提供对控件GUI元素的技术独立访问.用法:记录,导出为C#,进行编译,运行.对于专业用户而言,它是可以负担的.
My approach to this is to use existing tools for GUI test automation (since I want to automate on the user level and not on the technical detail level of the implementation).
A very useful one is Ranorex[^].
It''s a C# API that provides technology independent access to control GUI elements. Usage: Record, export as C#, compile, run. It''s affordable for professional users.


这篇关于IE Automation有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆