1<?php 2 3namespace Facebook\WebDriver\Chrome; 4 5use Facebook\WebDriver\Remote\Service\DriverService; 6 7class ChromeDriverService extends DriverService 8{ 9 /** 10 * The environment variable storing the path to the chrome driver executable. 11 * @deprecated Use ChromeDriverService::CHROME_DRIVER_EXECUTABLE 12 */ 13 const CHROME_DRIVER_EXE_PROPERTY = 'webdriver.chrome.driver'; 14 /** @var string The environment variable storing the path to the chrome driver executable */ 15 const CHROME_DRIVER_EXECUTABLE = 'WEBDRIVER_CHROME_DRIVER'; 16 /** 17 * @var string Default executable used when no other is provided 18 * @internal 19 */ 20 const DEFAULT_EXECUTABLE = 'chromedriver'; 21 22 /** 23 * @return static 24 */ 25 public static function createDefaultService() 26 { 27 $pathToExecutable = getenv(self::CHROME_DRIVER_EXECUTABLE) ?: getenv(self::CHROME_DRIVER_EXE_PROPERTY); 28 if ($pathToExecutable === false || $pathToExecutable === '') { 29 $pathToExecutable = static::DEFAULT_EXECUTABLE; 30 } 31 32 $port = 9515; // TODO: Get another port if the default port is used. 33 $args = ['--port=' . $port]; 34 35 return new static($pathToExecutable, $port, $args); 36 } 37} 38