admin管理员组文章数量:1416651
I am trying to test a page using the FF Selenium IDE plugin.
There is a menu structure like the following..
<ul class="parent">
<li class="child"><span><a href="something.html">link text</a></span></li>
<li class="child"><span><a href="somethingelse.html">other text</a></span></li>
<ul>
The li elements have a hover event bound to them. Those hover events register a click event on the actual link tag. (I have stripped out some of the JavaScript for simplification)
var menu = $('ul.parent');
$("> li.child", menu).hover(function () {
$(this).find('> a').click(function () {
$(this).parent().addClass('active-trail');
return false;
});
}, function() {});
If using Selenium I click one of these links then I would expect the handler to be called. It isn't and the click is simply executed (and the link followed, instead of false being returned).
I have tried (after reading other answers) mouseUp and mouseDown. I have also tried using fireEvent to firstly hover over the li (to activate the hover event) and then another fireEvent to click the anchor.. but that didn't work either.
So any help would be most appreciated. Just a basic demonstration of using Selenium to trigger a jquery supplied click handler would probably be enough to see me right!
Thanks, Patrick.
I am trying to test a page using the FF Selenium IDE plugin.
There is a menu structure like the following..
<ul class="parent">
<li class="child"><span><a href="something.html">link text</a></span></li>
<li class="child"><span><a href="somethingelse.html">other text</a></span></li>
<ul>
The li elements have a hover event bound to them. Those hover events register a click event on the actual link tag. (I have stripped out some of the JavaScript for simplification)
var menu = $('ul.parent');
$("> li.child", menu).hover(function () {
$(this).find('> a').click(function () {
$(this).parent().addClass('active-trail');
return false;
});
}, function() {});
If using Selenium I click one of these links then I would expect the handler to be called. It isn't and the click is simply executed (and the link followed, instead of false being returned).
I have tried (after reading other answers) mouseUp and mouseDown. I have also tried using fireEvent to firstly hover over the li (to activate the hover event) and then another fireEvent to click the anchor.. but that didn't work either.
So any help would be most appreciated. Just a basic demonstration of using Selenium to trigger a jquery supplied click handler would probably be enough to see me right!
Thanks, Patrick.
Share Improve this question asked Apr 14, 2011 at 5:20 patrickdaveypatrickdavey 2,0762 gold badges20 silver badges25 bronze badges2 Answers
Reset to default 2You are right with fireEvent()
, are you sure you were using it right?
If you want to fire the onClick
handler you would do fireEvent(locator, "click")
not fireEvent(locator, "onClick")
.
You probably are doing this right if you are using selenium IDE to generate the scripts.
Selenium is a bit dodgey in this area, I have had many similar problems.
Have you tried using xpath i.e.
selenium.Click("xpath=/descendant::li[contains(.,"something")][2]/x:a")
本文标签: javascriptSelenium IDEJQuery onclick handler not triggeredStack Overflow
版权声明:本文标题:javascript - Selenium IDE - JQuery onclick handler not triggered - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745256145a2650114.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论