Sep 5, 2011

Selenium sometimes does not click on anchor tag with onclick

I don't know why it does not perform the clicking.

This upsets me so much. I thought Selenium is stable.

Now I'm moving to watir-webdriver, which partially use selenium-webdriver. But it does not seem to have any problems.

According to a StackOverflow's answer, we should use fire_event('click') instead.

But Capybara does not support fire_event()..

---------------

I have tried fire_event() with Watir.

Here is the result:

It works with any element with the onclick attribute. But it does not work with <a href="http://www.google.com">.

---------------

I am getting to the bottom of this problem now.

If the link we click has no CSS class, then everything is ok even we switch to that Firefox and move mouse over it.

If the link has a CSS class, but the class has no :hover and no :active, then everything is still ok.

If the link has a CSS class, but the class has :hover but no :active, then everything is still ok.

If the link has a CSS class, but the class has :active but no :hover, then Selenium will fail to click on an anchor if you move mouse over Firefox being tested.

It is so strange....