views:

172

answers:

2

I have a link with an id:

<a href="#" onclick="return false();" id="lol">

In my test:

selenium.click("lol"); //when running the test, the click will just end up selecting the item, not firing off the frameworks javascript

This does not register the click the same! There is javascript that is part of a complex framework which will cause a div to popup. This works in firefox.

But this does work as a fix:

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

The fix does work. However, what is going on here? It seems that selenium.click() != [actual browser click event]. Can anyone help shed some light on these inner workings?

A: 

It is possible to click a link in a browser before the javascript is loaded. See this other question. One solution would be to wait for some element to be visible on the page that is put there by javascript.

iwein
I actually do wait for it to be visible on the page.
Zombies
A: 

Hi,

Selenium sometimes does not simulate click on javascript hrefs exactly. Maybe its the same issue here. A quick fix is to use a combination of selenium's mousedown and mouseup events. You can also consider using selenium.fireEvent("lol","click");. Revert back when you have tried these.

vamyip
I did try this. It did not work :( Oh... but perhaps mousedown and mouseup will work.
Zombies