WatIn的右键方法?
我试图右键单击树节点,但找不到该类的 Rightclick 方法。 Watin 是否具有右键单击操作功能?
谢谢
I am trying to right click on a tree node but can't find the Rightclick method of the class. Does Watin feature a right click action?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,您需要触发一个事件。如果只是 Internet Explorer,那么很容易传递所需的按钮值 2,即
如果您正在使用 FireFox,那么事情就没那么简单了,您可以阅读我的 较旧的问题,WatiN 开发人员友善地回复了。正如他在其他地方指出的那样,这应该在 WatiN 内。
同样的方法可以让您在 FireFox 中进行拖放。
No, you need to fire an event. If it's just Internet Explorer then it's easy to pass the required button value of 2, i.e.
If you are working with FireFox then it is not so simple, you can read my older question to which the WatiN developer kindly responded. As he notes elsewhere this should be within WatiN.
The same approach will let you drag and drop within FireFox.
您可以尝试:
它将启动JavaScript事件,该事件将打开“元素上下文”菜单,这通常是当您右键单击元素时发生的情况。它在 Internet Explorer 中对我有用,但我还没有在 FireFox 中测试过它。
You could try:
It will fire the JavaScript event that will open the elements context menu, which is what normally happens when you right click an element. It's worked for me in Internet Explorer, but I haven't tested it in FireFox.
Jen 就在这里(你应该接受她的回答)。
树节点上的
FireEvent("oncontextmenu")
对我来说也不起作用,直到我找到存在事件的元素。节点通常是
Div
控件,我是这样实现的:树节点(以及所有其他复杂的 DOM 结构)的主要问题是在正确的 DOM 元素上触发事件。
在大多数复杂的 DOM 结构中,事件在控件的
Init()
期间由 JavaScript 代码附加(例如 Telerik 就是这样做的)。因此您无法在 HTML 源代码中看到该事件。如果找不到事件,则必须使用 Visual Studio 等来调试 javascript。
为了理解我在说什么,这里有一个关于如何使用 JavaScript 附加事件的示例:
Jen is right here (you should accept her answer).
FireEvent("oncontextmenu")
on a Tree Node didn't work for me either until I found the element where the event was present.Nodes are usually
Div
controls and I achieve it like this :The main problem of the Tree Nodes (and all other complex DOM structure) is to fire the events on the good DOM element.
In most complex DOM structures, the events are attached by JavaScript code during the
Init()
of the controls (Telerik does it for example). So you can't see the event in the HTML source.If you can't find the events, you'll have to debug your javascript using Visual Studio for example.
To understand what I'am speaking about, here is an example on how events could be attached with JavaScript :