class App_Factory_RemoteWebDriver { public static function factory() { switch ($_SERVER['BROWSER_REQUESTED']) { case 'chrome': return self::createChrome(); break; case "ie": throw new Exception('Not implemented'); break; case 'firefox': default: return self::createFirefox(); break; } } public static function createChrome() { putenv("webdriver.chrome.driver=/path/to/chromedriver"); $service = ChromeDriverService::createDefaultService(); $service->start(); return ChromeDriver::start(DesiredCapabilities::chrome(), $service); } public static function createFirefox() { // these are just constants defined in bootstrap.php $seleniumUrl = isset($_SERVER['JENKINS_URL']) ? TEST_ENV_SELENIUM_SERVER : LOCAL_ENV_SELENIUM_SERVER; return RemoteWebDriver::create( $seleniumUrl, DesiredCapabilities::firefox() ); } }