Last active
December 9, 2025 15:22
-
-
Save gebi84/40862af6a0d441e9d00baddbf6d7b61f to your computer and use it in GitHub Desktop.
run behat test with panther in ddev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| default: | |
| formatters: | |
| pretty: | |
| verbose: true | |
| paths: false | |
| snippets: false | |
| extensions: | |
| DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~ | |
| Robertfausk\Behat\PantherExtension: ~ | |
| FriendsOfBehat\MinkDebugExtension: | |
| directory: etc/build | |
| clean_start: false | |
| screenshot: true | |
| Behat\MinkExtension: | |
| files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/" | |
| base_url: "https://example.project.test/" | |
| default_session: symfony | |
| javascript_session: panther_chrome | |
| sessions: | |
| symfony: | |
| symfony: ~ | |
| panther_chrome: | |
| panther: | |
| options: | |
| env: | |
| APP_ENV: 'test' | |
| hostname: '127.0.0.1' | |
| browser: 'chrome' | |
| webServerDir: '%paths.base%/public' # your custom public dir | |
| manager_options: | |
| chromedriver_arguments: | |
| - --log-path=/var/www/html/chromedriver.log | |
| - --verbose | |
| - --no-sandbox | |
| - --headless | |
| - --disable-dev-shm-usage | |
| - --disable-gpu | |
| - --window-size=1920,1080 | |
| - --ignore-certificate-errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ddev composer require --dev symfony/panther robertfausk/behat-panther-extension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .ddev/config.yaml | |
| hooks: | |
| post-start: | |
| - exec: "mkdir -p $HOME/.pki/nssdb" | |
| - exec: "certutil -d sql:$HOME/.pki/nssdb -N --empty-password" | |
| - exec: "certutil -d sql:$HOME/.pki/nssdb -A -t 'C,,' -n 'DDEV CA' -i /mnt/ddev-global-cache/mkcert/rootCA.pem" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #.ddev/web-build/Dockerfile | |
| ARG BASE_IMAGE | |
| FROM $BASE_IMAGE | |
| # Install Chromium, Driver, and NSS Tools (for certificates) | |
| RUN apt-get update && apt-get install -y chromium chromium-driver libnss3-tools | |
| ENV PANTHER_NO_SANDBOX=1 | |
| ENV PANTHER_CHROME_BINARY=/usr/bin/chromium | |
| ENV PANTHER_CHROMEDRIVER_BINARY=/usr/bin/chromedriver |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| declare(strict_types=1); | |
| require __DIR__ . '/vendor/autoload.php'; | |
| use Symfony\Component\Panther\Client; | |
| echo "Starting Panther Test...\n"; | |
| try { | |
| $client = Client::createChromeClient( | |
| null, // Use default chromedriver binary location | |
| [ | |
| '--no-sandbox', // CRITICAL for Docker | |
| '--headless', | |
| '--disable-dev-shm-usage', | |
| '--disable-gpu' | |
| ], | |
| ['external_base_uri' => 'https://127.0.0.1'] | |
| ); | |
| echo "Requesting google.com...\n"; | |
| $client->request('GET', 'https://www.google.com'); | |
| echo "Page title is: " . $client->getTitle() . "\n"; | |
| $client->takeScreenshot('panther-test.png'); | |
| echo "Screenshot saved as panther-test.png\n"; | |
| } catch (\Exception $e) { | |
| echo "Error: " . $e->getMessage() . "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment