Skip to content

Commit

Permalink
feat: allow selenium server with internal webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
daFish committed Mar 4, 2024
1 parent ef9a6f2 commit 55dad6c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,20 @@ 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 with the built-in web server, you need to configure the panther client as follows:

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

### 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
4 changes: 3 additions & 1 deletion src/PantherTestCaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ protected static function createPantherClient(array $options = [], array $kernel

if (PantherTestCase::FIREFOX === $browser) {
self::$pantherClients[0] = self::$pantherClient = Client::createFirefoxClient(null, null, $managerOptions, self::$baseUri);
} else {
} elseif (PantherTestCase::SELENIUM === $browser) {
self::$pantherClients[0] = self::$pantherClient = Client::createSeleniumClient($managerOptions['host'], $managerOptions['capabilities'], self::$baseUri, $options);
} else {
try {
self::$pantherClients[0] = self::$pantherClient = Client::createChromeClient(null, null, $managerOptions, self::$baseUri);
} catch (\RuntimeException $e) {
Expand Down

0 comments on commit 55dad6c

Please sign in to comment.