Skip to content

Commit

Permalink
fix: FF and Chrome don't need to use DesiredCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
tucksaun committed Mar 4, 2025
1 parent 20dae40 commit 6689afc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ServiceContainer/Driver/PantherFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Robertfausk\Behat\PantherExtension\ServiceContainer\PantherConfiguration;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\Panther\PantherTestCase;

/**
* @author Robert Freigang <[email protected]>
Expand Down Expand Up @@ -76,7 +77,7 @@ public function buildDriver(array $config)
$config['manager_options']['capabilities'][ChromeOptions::CAPABILITY] = $chromeOptions;
}

if (isset($config['manager_options']['capabilities'])) {
if (isset($config['options']['browser']) && isset($config['manager_options']['capabilities']) && PantherTestCase::SELENIUM === $config['options']['browser']) {
$config['manager_options']['capabilities'] = new Definition(DesiredCapabilities::class, [$config['manager_options']['capabilities']]);
}

Expand Down
9 changes: 5 additions & 4 deletions tests/Unit/Driver/PantherFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ public function test_build_chrome_driver_with_chrome_options_as_object_instead_o
$this->assertArrayHasKey('request_timeout_in_ms', $arguments[2]);
$this->assertSame('120000', $arguments[2]['request_timeout_in_ms']);
$this->assertArrayHasKey('capabilities', $arguments[2]);
$this->assertInstanceOf(Definition::class, $arguments[2]['capabilities']);
$this->assertSame(DesiredCapabilities::class, $arguments[2]['capabilities']->getClass());
$this->assertArrayHasKey('goog:chromeOptions', $arguments[2]['capabilities']->getArgument(0));
$chromeOptions = $arguments[2]['capabilities']->getArgument(0)['goog:chromeOptions'];
$this->assertArrayHasKey('goog:chromeOptions', $arguments[2]['capabilities']);
$chromeOptions = $arguments[2]['capabilities']['goog:chromeOptions'];

if ('goog:chromeOptions' === ChromeOptions::CAPABILITY) {
$this->assertInstanceOf(ChromeOptions::class, $chromeOptions);
Expand All @@ -126,6 +124,9 @@ public function test_build_chrome_driver_with_chrome_options_as_object_instead_o
public function test_build_selenium_driver_with_manager_options_capabilities_as_object_instead_of_array(): void
{
$config = [
'options' => [
'browser' => 'selenium',
],
'manager_options' => [
'capabilities' => [
'browserName' => 'firefox',
Expand Down

0 comments on commit 6689afc

Please sign in to comment.