我有一个带有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()!= [实际的浏览器点击事件]。任何人都可以帮助阐明这些内部运作吗?
答案 0 :(得分:1)
Selenium有时不会完全模拟点击javascript hrefs。也许这是同一个问题。快速解决方法是使用selenium的mousedown和mouseup事件的组合。您还可以考虑使用selenium.fireEvent("lol","click");
。你试过这些时还原它们。
答案 1 :(得分:0)
可以在加载javascript之前单击浏览器中的链接。见this other question。一种解决方案是等待一些元素在javascript放在那里的页面上可见。