Refactoring for use Selenium with PhantomJS driver.