【发布时间】:2010-06-23 14:56:11
【问题描述】:
我有一个带有 id 的链接:
<a href="#" onclick="return false();" id="lol">
在我的测试中:
selenium.click("lol"); //when running the test, the click will just end up selecting the item, not firing off the frameworks javascript
这和注册点击不一样!有一个 javascript 是一个复杂框架的一部分,它会导致一个 div 弹出。这适用于 Firefox。
但这确实可以解决问题:
selenium.click("lol"); //when running the test, the click will just end up selecting the item, not firing off the frameworks javascript
selenium.keyPress("lol", "\\13"); //press enter key, since the click ended up selecting it
修复确实有效。但是,这里发生了什么?似乎 selenium.click() != [实际浏览器点击事件]。任何人都可以帮助阐明这些内部工作原理吗?
【问题讨论】:
-
这个好像和stackoverflow.com/questions/633600/…差不多——好像不知道为什么会这样,但是可以使用fireEvent()来正确模拟事件。
标签: java junit selenium selenium-rc