In a simple form, .get()
navigates you to a URL.
Can anyone explain under what circumstances WebDriver returns control
before the page has finished, or even started, loading?
This kind of situation is pretty common nowadays - there are more and more pages out there that load asynchronously. Selenium would not wait for responses to outstanding AJAX requests or currently running scripts which can cause different errors while trying to access elements that are not present in DOM, or are not yet visible, or not yet having the desired data.
And this is, by the way, one of the reasons for the protractor
package to exist specifically for AngularJS application testing - it listens for an angular to signal "okay, I'm done with this page".
There are multiple ways to wait for a page to load:
Here is a perfect answer that should help in clearing things up.
Also see related topics with some great explanations of the problem: