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

WatiN FireEvent not passing event properties in FireFox(WatiN FireEvent 未在 FireFox 中传递事件属性)
本文介绍了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 中传递事件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)