WatiN FireEvent 未在 FireFox 中传递事件属性

3

本文介绍了WatiN FireEvent 未在 FireFox 中传递事件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

这已被记录为sourceforge 中的一个错误 虽然现在已删除.

This had been logged as a bug in sourceforge though now deleted.

我正在使用带有关联 jssh 的 FireFox 3.6.

I'm using FireFox 3.6 with associated jssh.

我可以在 Firebug 中看到没有设置事件属性.我正在尝试使用下面的代码进行拖放

I can see in Firebug that the Event Properties are not being set. I'm trying to drag and drop with code below

var mouseDownEvent = new NameValueCollection 
                         {{"button", "1"}, {"clientX", "0"}, {"clientY", "0"}};
firstStoryRow.FireEventNoWait("onmousedown", mouseDownEvent);

有解决方法可以传递这些属性但不是他们不好.

There are workarounds for passing these properties but not they're not nice.

有谁知道这是 WatiN 内部的真正限制还是我做错了什么?

Does anyone know if this is an genuine limitation within WatiN or something I'm doing wrong?

推荐答案

这确实是FireFox实现的一个短板.对于鼠标事件,所有给定的参数/值都将被忽略.这应该是固定的,并不难.我将在 SourceForge 上重新打开该问题.

This is indeed a shortcoming in the FireFox implementation. All the given parameters/values are ignored for mouse events. This should be fixed and is not that hard. I will reopen the issue on SourceForge.

要完成这项工作,您可以运行这段代码,这正是 WatiN 实际为您做的事情:

To make this work you could run this code, which is what WatiN is actually doing for you:

var jscriptref = firstStoryRow.GetJavascriptElementReference();

var fireeventcode = string.Format("var event = {0}.ownerDocument.createEvent('MouseEvents');",jscriptref);

// Params for the initMouseEvent:
// 'type', bubbles, cancelable, windowObject, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget )
fireeventcode += "event.initMouseEvent('mousedown', true, true, null, 0, 0, 0, 0, 0, false, false, false, false, 1, null);";
fireeventcode += string.Format("var res = {0}.dispatchEvent(event);", jscriptref);
fireeventcode += "if(res){true;}else{false;};";

// make it a NoWait call by wrapping it in a timer call.
fireeventcode = JSUtils.WrapCommandInTimer(fireeventcode);

var result = browser.Eval(fireeventcode);

如果结果 == 'true' 一切顺利.希望这对现在有所帮助,但这需要在下一个版本中修复.

If result == 'true' all went well. Hope this will help for now, but this needs to be fixed in the next release.

杰伦

这篇关于WatiN FireEvent 未在 FireFox 中传递事件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14