Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fix for change in chromedriver archive structure #1116

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/Console/ChromeDriverCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function handle()
if ($all || ($os === $currentOS)) {
$archive = $this->download($version, $os);

$binary = $this->extract($version, $archive);
$binary = $this->extract($archive);

$this->rename($binary, $os);
}
Expand Down Expand Up @@ -211,24 +211,37 @@ protected function download($version, $os)
/**
* Extract the ChromeDriver binary from the archive and delete the archive.
*
* @param string $version
* @param string $archive

This comment was marked as resolved.

* @return string
*/
protected function extract($version, $archive)
protected function extract($archive)
{
$zip = new ZipArchive;

$zip->open($archive);

$zip->extractTo($this->directory);
$binary = null;

for ($fileIndex = 0; $fileIndex < $zip->numFiles; $fileIndex++) {
$filename = $zip->getNameIndex($fileIndex);

if (Str::startsWith(basename($filename), 'chromedriver')) {
$binary = $filename;

$zip->extractTo($this->directory, $binary);

$binary = $zip->getNameIndex(version_compare($version, '115.0', '<') ? 0 : 1);
break;
}
}

$zip->close();

unlink($archive);

if (! $binary) {
throw new Exception('Could not extract the ChromeDriver binary.');
}

return $binary;
}

Expand Down
Loading