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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/PantherTestCaseTrait.php

View workflow job for this annotation

GitHub Actions / Coding Standards

Found violation(s) of type: braces

/*
* This file is part of the Panther project.
Expand Down Expand Up @@ -185,7 +185,9 @@

if (PantherTestCase::FIREFOX === $browser) {
self::$pantherClients[0] = self::$pantherClient = Client::createFirefoxClient(null, $browserArguments, $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, $browserArguments, $managerOptions, self::$baseUri);
} catch (\RuntimeException $e) {
Expand Down