Skip to content

Commit

Permalink
Persist original browser name (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
uuf6429 authored Nov 2, 2024
1 parent 759da70 commit 630842f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/WebdriverClassicDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct(
array $desiredCapabilities = [],
string $webDriverHost = 'http://localhost:4444/wd/hub'
) {
$this->browserName = self::BROWSER_NAME_ALIAS_MAP[$browserName] ?? $browserName;
$this->browserName = $browserName;
$this->desiredCapabilities = $this->initCapabilities($desiredCapabilities);
$this->webDriverHost = $webDriverHost;
}
Expand Down Expand Up @@ -771,6 +771,11 @@ protected function getWebDriver(): RemoteWebDriver
throw new DriverException('Base driver has not been created');
}

private function getNormalisedBrowserName(): string
{
return self::BROWSER_NAME_ALIAS_MAP[$this->browserName] ?? $this->browserName;
}

/**
* Detect and assign appropriate browser capabilities
*
Expand All @@ -784,7 +789,7 @@ private function initCapabilities(array $desiredCapabilities): DesiredCapabiliti
// Set defaults
$defaults = array_merge(
self::DEFAULT_CAPABILITIES['default'],
self::DEFAULT_CAPABILITIES[$this->browserName] ?? []
self::DEFAULT_CAPABILITIES[$this->getNormalisedBrowserName()] ?? []
);
foreach ($defaults as $key => $value) {
if ($caps->getCapability($key) === null) {
Expand All @@ -802,7 +807,7 @@ private function initCapabilities(array $desiredCapabilities): DesiredCapabiliti

private function getBrowserSpecificCapabilities(): ?DesiredCapabilities
{
switch ($this->browserName) {
switch ($this->getNormalisedBrowserName()) {
case WebDriverBrowserType::FIREFOX:
return DesiredCapabilities::firefox();

Expand Down

0 comments on commit 630842f

Please sign in to comment.