Click DIV 并不能产生“真实”的效果。 IE中点击操作
浏览器:打开兼容性视图的 Internet Explorer 8(测试的应用程序是为 IE7 编写的)。我有一个 div 元素,它看起来像浏览器中的复选框。当我手动单击它时,复选框会自动勾选。这是它的样子: http://img593.imageshack.us/g/divunchecked.jpg / 手动单击时,div 元素也会将其类属性从“x-grid3-check-col”更改为“x-grid3-check-col-on”。当我运行 Watin 测试并进行 Div.Click() 操作时,该元素不会检查自身。该元素的 Html:
<DIV class=x-grid3-check-col onclick=booleanInterviewColumnRender_OnClick(this);> </DIV>
我尝试过:
- 单击该 div 的父级中的 2 个(它被放置在另外 2 个 div 中)
- Div.MouseDown(); Div.MouseUp();
- Div.Firevent("onclick");
- NameValueCollection eventProperties = new NameValueCollection(); eventProperties.Add("按钮", "0"); Div.FireEvent("onmousedown", eventProperties); //鼠标左键单击
- Div.SetAttributeValue("class", "x-grid3-check-col-on"); Div.Refresh();
没有运气。
任何解决这个问题的想法都会很棒。
Browser: Internet Explorer 8 with compatibility view turned on (the tested application was written for IE7). I have a div element, which looks like a checkbox in the browser. When I manually click it the checkbox ticks itself. Here is how this looks like: http://img593.imageshack.us/g/divunchecked.jpg/ When clicked manually the div element also changes it's class attribute from "x-grid3-check-col" to "x-grid3-check-col-on". When I run a Watin test and make a Div.Click() operation the element doesn't check itself. Html of that element:
<DIV class=x-grid3-check-col onclick=booleanInterviewColumnRender_OnClick(this);> </DIV>
I have tried to:
- click 2 of the div's parents (it is placed in 2 other divs)
- Div.MouseDown();
Div.MouseUp();
- Div.Firevent("onclick");
- NameValueCollection eventProperties = new NameValueCollection();
eventProperties.Add("button", "0");
Div.FireEvent("onmousedown", eventProperties); //left mouse click
- Div.SetAttributeValue("class", "x-grid3-check-col-on");
Div.Refresh();
without luck.
Any ideas how to workaround this would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后一个解决方法是直接运行 javascript 调用。
如果你在你的div元素上放置一个id:
elementID
然后你调用
它会调用你放入你的属性中的onclick回调(你可以首先在控制台中尝试以确保javascript调用你的打回来)。
但是,我认为元素上的 WatiN 方法 .FireEvent 做了同样的事情,所以我不明白为什么你需要这个解决方法。
The last workaround is to run directly the javascript call.
if you put an id on your div element:
elementID
then you call
And it will call the onclick call back you put in your attribute (you can first try in the console to be sure that the javascript call your callback).
However, I think that the WatiN mehod .FireEvent on the Element does the same thing, so I don't understand why you need this workaround.