Misuse of waitForPageToLoad()

The common mistake that people usually do is to use waitForPageToLoad() function to wait for what appears to be a webpage being loaded. But, in fact, it is Ajax or JavaScript that is doing some changes to a portion of the webpage. As a result, the waitForPageToLoad() function will always time out because it is expecting for the whole webpage to load that never happened.

So, the next time that you get a time out on waitForPageToLoad() function even though that you swear you have allocated more than enough time to it, then you are not using waitForPageToLoad() function correctly. A simple trick to know is to replace the waitForPageToLoad() function with a pause. If Selenium is able to execute the next instruction, then you shouldn't use the waitForPageToLoad() function. Perhaps, you should consider to write a new function to wait for what you expected.