{"id":22426398,"url":"https://github.com/robertfausk/behat-panther-extension","last_synced_at":"2025-08-01T08:33:26.261Z","repository":{"id":34812710,"uuid":"183897457","full_name":"robertfausk/behat-panther-extension","owner":"robertfausk","description":"Run your behat tests in a headless chrome/firefox - Symfony Panther extension for Behat","archived":false,"fork":false,"pushed_at":"2024-05-07T18:08:21.000Z","size":63,"stargazers_count":30,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-24T16:08:16.389Z","etag":null,"topics":["behat","behat-extension","extension","mink","panther","panther-driver","php","symfony","symfony-panther","symfony-panther-extension"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/robertfausk/behat-panther-extension","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertfausk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-28T11:09:31.000Z","updated_at":"2024-06-27T19:47:55.000Z","dependencies_parsed_at":"2024-04-17T10:46:48.647Z","dependency_job_id":"71ee388b-08a5-40a6-8712-06c1b8f3b3f7","html_url":"https://github.com/robertfausk/behat-panther-extension","commit_stats":{"total_commits":61,"total_committers":3,"mean_commits":"20.333333333333332","dds":0.09836065573770492,"last_synced_commit":"a3bc1bbbb712e2eadef36ff9c9c881f62d8165cd"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfausk%2Fbehat-panther-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfausk%2Fbehat-panther-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfausk%2Fbehat-panther-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfausk%2Fbehat-panther-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertfausk","download_url":"https://codeload.github.com/robertfausk/behat-panther-extension/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228356339,"owners_count":17907191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behat","behat-extension","extension","mink","panther","panther-driver","php","symfony","symfony-panther","symfony-panther-extension"],"created_at":"2024-12-05T19:18:13.859Z","updated_at":"2025-08-01T08:33:26.240Z","avatar_url":"https://github.com/robertfausk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BehatPantherExtension\n\n[![Latest Stable Version](https://poser.pugx.org/robertfausk/behat-panther-extension/v/stable.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension)\n[![Latest Unstable Version](https://poser.pugx.org/robertfausk/behat-panther-extension/v/unstable.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension)\n[![Total Downloads](https://poser.pugx.org/robertfausk/behat-panther-extension/downloads.svg)](https://packagist.org/packages/robertfausk/behat-panther-extension)\n[![Monhtly Downloads](https://img.shields.io/packagist/dm/robertfausk/behat-panther-extension?style=flat\u0026color=blue)](https://img.shields.io/packagist/dm/robertfausk/behat-panther-extension)\n[![Daily Downloads](https://img.shields.io/packagist/dd/robertfausk/behat-panther-extension?style=flat\u0026color=blue)](https://img.shields.io/packagist/dm/robertfausk/behat-panther-extension)\n[![Tests](https://github.com/robertfausk/behat-panther-extension/actions/workflows/ci.yml/badge.svg)](https://github.com/robertfausk/behat-panther-extension/actions/workflows/ci.yml)\n[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/robertfausk/behat-panther-extension/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/robertfausk/behat-panther-extension/)\n[![Code Coverage](https://scrutinizer-ci.com/g/robertfausk/behat-panther-extension/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/robertfausk/behat-panther-extension/)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)\n[![PHP Version Require](http://poser.pugx.org/robertfausk/behat-panther-extension/require/php)](https://packagist.org/packages/robertfausk/behat-panther-extension)\n[![Open Issues](https://img.shields.io/github/issues-raw/robertfausk/behat-panther-extension?style=flat)](https://github.com/robertfausk/behat-panther-extension/issues)\n[![Closed Issues](https://img.shields.io/github/issues-closed-raw/robertfausk/behat-panther-extension?style=flat)](https://github.com/robertfausk/behat-panther-extension/issues?q=is%3Aissue+is%3Aclosed)\n[![Contributors](https://img.shields.io/github/contributors/robertfausk/behat-panther-extension?style=flat)](https://github.com/robertfausk/behat-panther-extension/graphs/contributors)\n![Contributors](https://img.shields.io/maintenance/yes/2027?style=flat)\n[![Dependents](http://poser.pugx.org/robertfausk/behat-panther-extension/dependents)](https://packagist.org/packages/robertfausk/behat-panther-extension/dependents)\n\nSymfony Panther extension for Behat\n\n## Install\n\n```BASH\ncomposer require --dev robertfausk/behat-panther-extension\n```\n\n## Usage example\n\n* Add ```Robertfausk\\Behat\\PantherExtension: ~``` to your behat.yml.\n* Use ```panther``` session in ```Behat\\MinkExtension```. \n* The extension will use options of ```symfony/panther``` by default.\nHave a look at ```PantherTestCaseTrait::$defaultOptions``` for this.\n* Following are some examples with all sessions using mink-panther-driver:\n    ```YAML\n    # in behat.yml\n        extensions:\n            Robertfausk\\Behat\\PantherExtension: ~ # no configuration here\n            Behat\\MinkExtension:\n               javascript_session: javascript_chrome\n               sessions:\n                   default:\n                       panther: ~\n                   javascript:\n                       panther:\n                           options: ~\n                   javascript_chrome:\n                       panther:\n                           options:\n                               browser: 'chrome'\n                               webServerDir: '%paths.base%/public' # your custom public dir\n                   javascript_firefox:\n                       panther:\n                           options:\n                               browser: 'firefox'\n                   javascript_with_all_options:\n                       panther:\n                           options:\n                               env:\n                                   APP_ENV: 'dev'\n                               hostname: '127.0.0.1'    \n                           kernel_options: ~ # unused by behat-panther-extension cause it does not extend KernelTestCase\n                           manager_options:\n                               connection_timeout_in_ms: 5000\n                               request_timeout_in_ms: 120000\n    ```\n\n#### Example on how to pass arguments to ChromeDriver binary\n\nSee also https://chromedriver.chromium.org/logging\n\n```YAML\n# in behat.yml enable logging\n    extensions:\n        Robertfausk\\Behat\\PantherExtension: ~\n        Behat\\MinkExtension:\n           javascript_session: javascript\n           sessions:\n               javascript:\n                   panther:\n                       manager_options:\n                           chromedriver_arguments:\n                               - --log-path=/var/www/html/chromedriver.log\n                               - --verbose\n```\n\n#### Example on how to test for a downloaded file\n\n```YAML\n# in behat.yml ensure that chrome saves files to the destination you want\n    extensions:\n        Robertfausk\\Behat\\PantherExtension: ~\n        Behat\\MinkExtension:\n           javascript_session: javascript\n           files_path: '%paths.base%/tests/files'\n           sessions:\n               javascript:\n                   panther:\n                       manager_options:\n                           capabilities:\n                                goog:chromeOptions:\n                                    prefs:\n                                        download.default_directory: '/var/www/html/tests/files/Downloads'\n```\n\n```GHERKIN\n# acme_download.feature\nFeature: Acme files can be downloaded\n\n  Background:\n    Given there is no file in download directory\n    # additionally setup your database entries etc. if needed\n\n  @javascript\n  Scenario: As an user with role Admin i can download an existing acme file\n    Given I am authenticated as \"admin@acme.de\"\n    And I am on \"/acme-file-list\"\n    Then I wait for \"acme.pdf\" to appear\n    When I click on test element \"button-acme-download\"\n    Then I can find file \"acme.pdf\" in download directory\n```\n\n```PHP\n\u003c?php\n#AcmeContext.php\n\nuse Assert\\Assertion;\nuse Behat\\Mink\\Element\\NodeElement;\nuse Symfony\\Component\\Filesystem\\Filesystem;\nuse Symfony\\Component\\Finder\\Finder;\n\n\n/**\n * @When /^I click on test element \"([^\"]*)\"$/\n *\n * @param string $locator\n */\npublic function iClickOnTestElement(string $locator): void\n{\n    $btn = $this-\u003egetTestElement($locator);\n    $btn-\u003eclick();\n}\n\n/**\n * @Given /^there is no file in download directory$/\n */\npublic function thereIsNoFileinDownloadDirectory(): void\n{\n    $finder = new Finder();\n    $fs = new Filesystem();\n    $fs-\u003eremove($finder-\u003ein($this-\u003egetDownloadDirectory())-\u003efiles());\n}\n\n/**\n * @Then /^I can find file \"([^\"]*)\" in download directory$/\n */\npublic function iCanFindFileInDownloadDirectory($filename)\n{\n    $fs = new Filesystem();\n    $path = \\sprintf('%s%s%s', $this-\u003egetDownloadDirectory(), DIRECTORY_SEPARATOR, $filename);\n    $this-\u003espin(\n        static function () use ($fs, $path): void {\n            $isFileExisting = $fs-\u003eexists($path);\n            Assertion::true($isFileExisting);\n        },\n    );\n    Assertion::true($fs-\u003eexists($path));\n}\n\nprivate function getDownloadDirectory(): string\n{\n    return \\sprintf('%s%sDownloads', $this-\u003egetMinkParameter('files_path'), DIRECTORY_SEPARATOR);\n}\n\nprivate function getTestElement(string $dataTestLocator, int $tries = 25): NodeElement\n{\n    return $this-\u003egetNodeElement(\"[data-test='$dataTestLocator']\", $tries);\n}\n\nprivate function spin(\\Closure $closure, ?int $tries = 25): ?NodeElement\n{\n    for ($i = 0; $i \u003c= $tries; $i++) {\n        try {\n            return $closure();\n        } catch (\\Throwable $e) {\n            if ($i === $tries) {\n                throw $e;\n            }\n        }\n\n        \\usleep(100000); // 100 milliseconds\n    }\n}\n```\n                               \n### How to upgrade?\n\n Have a look at [CHANGELOG](CHANGELOG.md) for detailed information.\n\n## How to contribute?\n\nStart docker-compose with php version of your choice. At the moment the following php versions can be used with docker-compose: `php7.2`, `php7.3`, `php7.4`, `php8.0`, `php8.1`, `php8.2`, `php8.3` and `php8.4`.\n\nE.g. you can start a container like this:\n\n    docker-compose up php8.2\n\nUpgrade scenario lock files:\n\n    docker-compose run php8.2 composer update\n\nRun phpunit tests:\n\n    docker-compose run php8.2 vendor/bin/phpunit\n\nIf you want to start up all containers at once and keep them running in background then run the following:\n```\ndocker-compose up -d\n```\n\nIf you want to execute tests for scenario `symfony6` and `php8.2` then run the following:\n```\ndocker-compose run php8.2 composer scenario symfony6\ndocker-compose run php8.2 vendor/bin/bdi detect drivers\ndocker-compose run php8.2 vendor/bin/behat --config=tests/Behat/behat.yml\ndocker-compose run php8.2 vendor/bin/phpunit\n```\n\nOr if you want to execute tests for scenario `symfony7` and `php8.4` then run the following:\n```\ndocker-compose run php8.4 composer scenario symfony7\ndocker-compose run php8.4 vendor/bin/bdi detect drivers\ndocker-compose run php8.4 vendor/bin/behat --config=tests/Behat/behat.yml\ndocker-compose run php8.4 vendor/bin/phpunit\n```\n\nSee also https://github.com/g1a/composer-test-scenarios for more information about scenarios.\n\n## Credits\n\nCreated by Robert Freigang [robertfausk](https://github.com/robertfausk).\n\nBehatPantherExtension is built on top of [symfony/panther](https://github.com/symfony/panther) and [robertfausk/mink-panther-driver](https://github.com/robertfausk/mink-panther-driver).\nIt is for usage with [Behat and Mink](http://behat.org/en/latest/cookbooks/integrating_symfony2_with_behat.html#initialising-behat). \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfausk%2Fbehat-panther-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertfausk%2Fbehat-panther-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfausk%2Fbehat-panther-extension/lists"}