wait_for_dom implementation for Selenium