Here's what I do:
selenium.click("link=mylink");
selenium.waitForPageToLoad(60000);
// do something, then navigate to a different page
// (window focus is never changed in-between)
selenium.click("link=mylink");
selenium.waitForPageToLoad(60000);
The link "mylink" does exist, the first invocation of click() always works. But the second click() sometimes seems to work, sometimes not.
It looks like the click() event is not triggered at all, because the page doesn't even start to load. Unfortunately this behaviour is underterministic.
Here's what I already tried:
Set longer time timeout
=> did not helpWait for an element present after loading one page
=> doesn't work either since the page does not even start to load
For now I ended up invoking click() twice, so:
selenium.click("link=mylink");
selenium.waitForPageToLoad(60000);
// do something, then navigate to a different page
// (window focus is never changed in-between)
selenium.click("link=mylink");
selenium.click("link=mylink");
selenium.waitForPageToLoad(60000);
That will work, but it's not a really nice solution. I've also seen in another forum where someone suggested to write something like a 'clickAndWaitWithRetry':
try {
super.click("link=mylink");
super.waitForPageToLoad(60000);
}
catch (SeleniumException e) {
super.click("link=mylink");
super.waitForPageToLoad(60000);
}
But I think that is also not a proper solution.... Any ideas/explanations why the click() event is sometimes not triggered?
I am running into this issue now also. From my usages of this, it seems like the following is the most consistent:
Not exactly sure why that would be. But it seems that if you do:
Then you could end up waiting for a page that has already been loaded (i.e. you end up waiting forever).
I dug into the Selenium source code and found this nugget:
...
Basically, this is doing the following:
However, as the comment states, the first thing necessary is to use the :wait_for command immediately after.
And of course... switching the order puts you into the same wait forever state.
Without knowing all the details of Selenium, it seems as though Selenium needs to register the :wait_for trigger when it is passed as an option with click. Otherwise, you could end up waiting forever if you somehow tell Selenium to wait the very instant before :wait_for is called.
Selenium click() event seems not to be always triggered => results in timeout?
Try selenium.pause before Selenium.click command. I have tried all above but none of them seems to resolve our problem. So finally we got a Magic selenium.pause which solved problem for me..
Hope this will solve your problem as well
I am having the same issue :( with selenium IDE 1.0.10 , phpunit 3.5 , selenium RC server 1.0.3
Sometimes, seemingly randomly, Selenium just doesn't like to click certain anchor tags. I am not sure what causes it, but it happens. I find in those cases w/ a troublesome link instead of doing
do
As others have stated above me, I have specifically had issues with anchor tags that appear as follows:
Here this one will work:
Make sure you are increasing the timeout in the correct place. The lines you posted are:
This wait is for the page to load that comes back After the click. But the problem you describe is that it is failing when trying to do the click. So, make sure to increase the wait Before this one.