WatiN FireEvent在FireFox中不传递事件属性 [英] WatiN FireEvent not passing event properties in FireFox
问题描述
这是记录为sourceforge中的错误虽然现在已被删除。
This had been logged as a bug in sourceforge though now deleted.
我正在使用FireFox 3.6与关联的jssh。
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);
有解决方法但不是不太好。
谁知道这是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);
如果result =='true'一切顺利。
希望这将有助于现在,但这需要在下一个版本中解决。
If result == 'true' all went well. Hope this will help for now, but this needs to be fixed in the next release.
Jeroen
这篇关于WatiN FireEvent在FireFox中不传递事件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!