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

feat: allow selenium server with internal webserver #621

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,22 @@ class SecondDomainTest extends PantherTestCase

To use a proxy server, set the following environment variable: `PANTHER_CHROME_ARGUMENTS='--proxy-server=socks://127.0.0.1:9050'`

### Using Selenium With the Built-In Web Server

If you want to use [Selenium Grid](https://www.selenium.dev/documentation/grid/) with the built-in web server, you need to configure the Panther client as follows:

```php
$client = Client::createPantherClient(
options: [
'browser' => PantherTestCase::SELENIUM,
],
managerOptions: [
'host' => 'http://selenium-hub:4444', // the host of the Selenium Server (Grid)
'capabilities' => DesiredCapabilities::firefox(), // the capabilities of the browser
],
);
```

### Accepting Self-signed SSL Certificates

To force Chrome to accept invalid and self-signed certificates, set the following environment variable: `PANTHER_CHROME_ARGUMENTS='--ignore-certificate-errors'`
Expand Down
2 changes: 2 additions & 0 deletions src/PantherTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class PantherTestCase extends WebTestCase

public const CHROME = 'chrome';
public const FIREFOX = 'firefox';
public const SELENIUM = 'selenium';

protected function tearDown(): void
{
Expand All @@ -44,6 +45,7 @@ abstract class PantherTestCase extends TestCase

public const CHROME = 'chrome';
public const FIREFOX = 'firefox';
public const SELENIUM = 'selenium';

protected function tearDown(): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/PantherTestCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ protected static function createPantherClient(array $options = [], array $kernel

if (PantherTestCase::FIREFOX === $browser) {
self::$pantherClients[0] = self::$pantherClient = PantherClient::createFirefoxClient(null, $browserArguments, $managerOptions, self::$baseUri);
} elseif (PantherTestCase::SELENIUM === $browser) {
self::$pantherClients[0] = self::$pantherClient = PantherClient::createSeleniumClient($managerOptions['host'], $managerOptions['capabilities'] ?? null, self::$baseUri, $options);
} else {
try {
self::$pantherClients[0] = self::$pantherClient = PantherClient::createChromeClient(null, $browserArguments, $managerOptions, self::$baseUri);
Expand Down
Loading