Skip to content

Commit

Permalink
Get ChromeDriver's latest release in Robo task.
Browse files Browse the repository at this point in the history
The Robo task will now automatically install the latest version of
ChromeDriver instead of installing a static version.

Also improves wording/grammar in various places.
  • Loading branch information
connorshea committed Jun 7, 2019
1 parent be18dab commit 95c4179
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions lib/Robo/Plugin/Commands/TestEnvironmentCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public function configureTests(
} elseif ($os->isOsLinux()) {
$this->say('Linux detected');
$this->installUnixEnvironmentVariables($opts);
} elseif ($os->isOsMacOsX()) {
$this->say('Mac OS X detected');
} elseif ($os->isOsMacOSX()) {
$this->say('macOS detected');
$this->installUnixEnvironmentVariables($opts);
} elseif ($os->isOsBSD()) {
$this->say('BSD detected');
Expand Down Expand Up @@ -172,8 +172,8 @@ public function fakeTravis(
} elseif ($os->isOsLinux()) {
$this->say('Linux detected');
$this->installUnixEnvironmentVariables($opts);
} elseif ($os->isOsMacOsX()) {
$this->say('Mac OS X detected');
} elseif ($os->isOsMacOSX()) {
$this->say('macOS detected');
$this->installUnixEnvironmentVariables($opts);
} elseif ($os->isOsBSD()) {
$this->say('BSD detected');
Expand All @@ -182,9 +182,9 @@ public function fakeTravis(
$this->say('Solaris detected');
$this->installUnixEnvironmentVariables($opts);
} elseif ($os->isOsUnknown()) {
throw new \DomainException('Unknown Operating system');
throw new \DomainException('Unknown operating system');
} else {
throw new \DomainException('Unable to detect Operating system');
throw new \DomainException('Unable to detect operating system');
}

$this->say('Fake Travis Environment Complete');
Expand Down Expand Up @@ -318,31 +318,34 @@ private function toUnixEnvironmentVariables(array $opts)


/**
* @param string $version
* Gets the URL for installing the latest version of ChromeDriver.
* @return string url
*/
private function getChromeWebDriverUrl($version = '2.38')
private function getChromeWebDriverUrl()
{
$os = new OperatingSystem();
$latestRelease = file_get_contents('https://chromedriver.storage.googleapis.com/LATEST_RELEASE', false);

if ($os->isOsWindows()) {
$this->say('Windows detected');
return 'https://chromedriver.storage.googleapis.com/' . $version . '/chromedriver_win32.zip';
return 'https://chromedriver.storage.googleapis.com/' . $latestRelease . '/chromedriver_win32.zip';
} elseif ($os->isOsLinux()) {
$this->say('Linux detected');
return 'https://chromedriver.storage.googleapis.com/' . $version . '/chromedriver_linux64.zip';
} elseif ($os->isOsMacOsX()) {
$this->say('Mac OS X detected');
return 'https://chromedriver.storage.googleapis.com/' . $version . '/chromedriver_mac64.zip';
return 'https://chromedriver.storage.googleapis.com/' . $latestRelease . '/chromedriver_linux64.zip';
} elseif ($os->isOsMacOSX()) {
$this->say('macOS detected');
return 'https://chromedriver.storage.googleapis.com/' . $latestRelease . '/chromedriver_mac64.zip';
} elseif ($os->isOsBSD()) {
$this->say('BSD detected');
throw new \DomainException('Unsupported Operating system');
throw new \DomainException('Unsupported operating system');
} elseif ($os->isOsSolaris()) {
$this->say('Solaris detected');
throw new \DomainException('Unsupported Operating system');
throw new \DomainException('Unsupported operating system');
} elseif ($os->isOsUnknown()) {
throw new \DomainException('Unknown Operating system');
throw new \DomainException('Unknown operating system');
} else {
throw new \DomainException('Unable to detect operating system');
}
throw new \DomainException('Unable to detect Operating system');
}

/**
Expand Down Expand Up @@ -395,29 +398,30 @@ private function runChromeWebDriver($basePath, $urlBase = '/wd/hub')
. DIRECTORY_SEPARATOR
. 'chromedriver';
chmod($binPath, 100);
} elseif ($os->isOsMacOsX()) {
} elseif ($os->isOsMacOSX()) {
$this->say('macOS detected');
$binPath = $basePath
. DIRECTORY_SEPARATOR
. 'chromedriver';
chmod($binPath, 100);
} elseif ($os->isOsBSD()) {
$this->say('BSD detected');
throw new \DomainException('Unsupported Operating system');
throw new \DomainException('Unsupported operating system');
} elseif ($os->isOsSolaris()) {
$this->say('Solaris detected');
throw new \DomainException('Unsupported Operating system');
throw new \DomainException('Unsupported operating system');
} elseif ($os->isOsUnknown()) {
throw new \DomainException('Unknown Operating system');
throw new \DomainException('Unknown operating system');
} else {
throw new \DomainException('Unable to detect Operating system');
throw new \DomainException('Unable to detect operating system');
}

if (!file_exists($binPath)) {
throw new \RuntimeException('Unable to find chrome driver ' . $binPath);
throw new \RuntimeException('Unable to find ChromeDriver ' . $binPath);
}

$this->say('Hint: open terminal and run `'.$os->toOsPath('./vendor/bin/codecept').'run [test suite] --env chrome-driver`');
$this->say('Starting Chrome Driver');
$this->say('Hint: open terminal and run `'.$os->toOsPath('./vendor/bin/codecept').' run [test suite] --env chrome-driver`');
$this->say('Starting ChromeDriver');
$this->_exec(
$binPath
. ' --url-base='
Expand Down

0 comments on commit 95c4179

Please sign in to comment.