{"id":17172958,"url":"https://github.com/20tab/django-bdd-toolkit","last_synced_at":"2025-04-13T16:12:52.041Z","repository":{"id":49708058,"uuid":"114631319","full_name":"20tab/django-bdd-toolkit","owner":"20tab","description":"A Django2+, Py3.6+, Selenium3+, PageObject pattern framework to easily setup BDD tests","archived":false,"fork":false,"pushed_at":"2021-06-10T18:16:03.000Z","size":53,"stargazers_count":15,"open_issues_count":6,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T16:12:46.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/20tab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-18T11:06:46.000Z","updated_at":"2022-11-14T17:11:43.000Z","dependencies_parsed_at":"2022-09-01T00:22:50.019Z","dependency_job_id":null,"html_url":"https://github.com/20tab/django-bdd-toolkit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-bdd-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-bdd-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-bdd-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-bdd-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/20tab","download_url":"https://codeload.github.com/20tab/django-bdd-toolkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741195,"owners_count":21154255,"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":[],"created_at":"2024-10-14T23:49:08.911Z","updated_at":"2025-04-13T16:12:52.019Z","avatar_url":"https://github.com/20tab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-bdd-toolkit\nA Django2+, Python 3.6+, Selenium3+ pattern framework to easily setup BDD tests, using [behave](https://github.com/behave/behave), [behave-django](https://github.com/behave/behave-django), and [splinter](https://github.com/cobrateam/splinter).\n\n## Install\nIn a Python 3.6, Django 2+ environment, install the following packages:\n\n```shell\npip install behave behave-django selenium splinter\n```\n\n### Behave\n\n*If you have some behave related errors try to install it from GitHub as explained in the [behave documentations](http://behave.readthedocs.io/en/latest/install.html#using-the-github-repository).*\n\nRun the following command to install the latest version from the GitHub repository:\n\n```shell\npip install git+https://github.com/behave/behave\n```\nor (faster option)\n```shell\npip install https://github.com/behave/behave/archive/master.zip#egg=behave\n```\n\n## Configuration\nCreate a `behave.ini` (or `tox.ini`) file in the Django project root directory containing the paths to the testing directories (or the `feature` directory inside of them), e.g.:\n```ini\n[behave]\npaths = tests/bdd/\n        myapp/tests/bdd/\n        myotherapp/tests/bdd/\n```\n\n#### Django Settings\n- In order for the tests to locate your project static files, it is important to correctly set the `STATICFILES_DIRS` (e.g.: `STATICFILES_DIRS = [os.path.abspath('static'),]`)\n\n- In order to define the default browser for Selenium testing, set `BDD_DEFAULT_BROWSER` to either `'chrome'` (the default) or `'firefox'`.\n\n- To enable headless testing (PhantomJS is deprecated), set `BDD_HEADLESS_BROWSER` to `True` (default is `False`).\n\n- To enable incognito mode for browsers, set `BDD_INCOGNITO_BROWSER` to `True` (default is `False`).\n\n- To enable fullscreen mode for browsers, set `BDD_FULLSCREEN_BROWSER` to `True` (default is `False`).\n\n**Tips**\nDo not forget to include `behave_django` among the installed apps:\n\n```python\nINSTALLED_APPS += ['behave_django']\n```\n\n## Testing\nInside each BDD testing directory, test files should be created according to the following structure (the `steps` directory is often found inside the `feature` directory):\n```shell\nbdd/\n    __init__.py\n    features/\n        myfeature.feature\n    pages/\n        __init__.py\n        mypage.py\n    steps/\n        __init__.py\n        mysteps.py\n```\n\n### 1. Features\nDefine BDD features written in [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) in `.feature` files inside a directory named `features`. In case a web UI test is performed, the Chrome browser is used by default, nonetheless this can be changed decorating a certain Scenario with `@browser.firefox` or `@browser.phantomjs`.\n\n**Tips**\nFeatures and scenarios can be tagged as described [here](https://behave.readthedocs.io/en/latest/tutorial.html#controlling-things-with-tags), this allows running only a specific subset of tests (e.g. those related to a given user story).\n\n### 2. Steps\nImplement each step defined in the feature files, in Python files inside the `steps` directory. Use `behave` decorators: `given`, `when` and `then` (`and` and `but` steps should be decorated as the preceding main step).\n\n### 3. Pages (Optional)\nIn case a web UI is being tested, it is useful to define page objects tailored on specific web pages. `splinter` is used to provide basic interaction with the pages and lets the user choose which `selenium` driver (e.g. Chrome, Firefox or PhantomJS) to use. Each page class should be defined in Python files inside the `pages` directory and should inherit from the `BasePage` class found in `pages/base.py`. Each page is independent and might be instantiated with a different driver. The tools provided by `splinter` are accessible (and extendable) via `self.browser` (e.g. it might be convenient to define locators as the logo one in the sample project).\n\n## Resources\n* [behave documentation](https://behave.readthedocs.io/en/latest/index.html)\n* [behave-django documentation](https://behave-django.readthedocs.io/en/latest/)\n* [splinter documentation](https://splinter.readthedocs.io/en/latest/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fdjango-bdd-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F20tab%2Fdjango-bdd-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fdjango-bdd-toolkit/lists"}