WatiN FireEvent 未在 FireFox 中传递事件属性 [英] WatiN FireEvent not passing event properties in FireFox

查看:24
本文介绍了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 中传递事件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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