-Moved the waitForElement trick to a function.
This will hopefully be added to selenium-webdriver eventually.