How do we know that the page we are interested in has loaded and is ready for us to start running our scripts against?
It sounds like a simple question; however, it is one of the things that always catches people out. If you are ever asked why a script doesn't work when the code seems sensible, your usual reply should probably be, It's a wait problem!
Wait problems are probably the most common error in Selenium scripts; shockingly, most of the time, people don't even know they have them. JavaScript-heavy sites are especially prone to wait problems, but you can run into them with sites that don't use much JavaScript as well.
Why are wait problems so prevalent? It's largely due to people not thinking about the consequences of external variables when they write their scripts.
Let's take a made-up scenario. We have a page...