繁体   English   中英

Selenium:为什么click()的行为与firefox中的行为不同?

[英]Selenium: Why does click() not behave like it does in firefox?

我有一个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()!= [实际的浏览器点击事件]。 任何人都可以帮助阐明这些内部运作吗?

Selenium有时不会完全模拟点击javascript hrefs。 也许这是同一个问题。 快速解决方法是使用selenium的mousedown和mouseup事件的组合。 你也可以考虑使用selenium.fireEvent("lol","click"); 尝试这些时还原。

在加载javascript之前,可以在浏览器中单击链接。 看到这个其他问题 一种解决方案是等待一些元素在javascript放在那里的页面上可见。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM