You can set a JavaScript variable in your WepPage that gets set once it's been loaded. You could put it anywhere, but if you're using jQuery, $(document).onReady
isn't a bad place to start. If not, then you can put it in a <script>
tag at the bottom of the page.
The advantage of this method as opposed to checking for element visibility is that you know the exact state of the page after the wait
statement executes.
... All my page content ...
<script> window.TestReady = true; </script></body></html>
And in your test (C# example):
// The timespan determines how long to wait for any 'condition' to return a value
// If it is exceeded an exception is thrown.
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5.0));
// Set the 'condition' as an anonymous function returning a boolean
wait.Until<Boolean>(delegate(IWebDriver d)
{
// Check if our global variable is initialized by running a little JS
return (Boolean)((IJavaScriptExecutor)d).ExecuteScript("return typeof(window.TestReady) !== 'undefined' && window.TestReady === true");
});