{"id":17309883,"url":"https://github.com/eliotjones/behave-selenium-template","last_synced_at":"2025-03-27T00:24:09.644Z","repository":{"id":46202467,"uuid":"47034479","full_name":"EliotJones/behave-selenium-template","owner":"EliotJones","description":"A project template for writing BDD style web testing projects using selenium for python and behave","archived":false,"fork":false,"pushed_at":"2021-11-07T14:59:28.000Z","size":8406,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T06:12:25.553Z","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/EliotJones.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":"2015-11-28T18:15:46.000Z","updated_at":"2015-11-28T19:06:57.000Z","dependencies_parsed_at":"2022-09-25T06:01:30.708Z","dependency_job_id":null,"html_url":"https://github.com/EliotJones/behave-selenium-template","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/EliotJones%2Fbehave-selenium-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliotJones%2Fbehave-selenium-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliotJones%2Fbehave-selenium-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EliotJones%2Fbehave-selenium-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EliotJones","download_url":"https://codeload.github.com/EliotJones/behave-selenium-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245757046,"owners_count":20667274,"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-15T12:33:24.333Z","updated_at":"2025-03-27T00:24:09.614Z","avatar_url":"https://github.com/EliotJones.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to behave with Selenium #\n\nThis is a project template for using BDD style tests to test a web application.\n\nThe browser is driven by Selenium and performs BDD style steps defined using the [behave library][link0] for Python.\n\nThis template is designed to work with Python 3.5 on Windows 7+.\n\n\n\n## Installation ##\n\n### Pre-Requisites ###\n\nHave installed at least one of:\n\n+ Chrome\n+ Firefox\n+ Internet Explorer \n\nAdditionally you must have Python 3.5 installed and set-up on the Path:\n\n+ Install [Python 3.5 or above][link1] for Windows. \n+ Make sure Python is set in the Path (```Control Panel \u003e System \u003e Advanced System Settings \u003e  Environment Variables``` and add ```C:\\root\\to\\Python[version]\\Scripts\\```)\n\n### Steps ###\n\n1. Open a command prompt in the root of the project and call ```configure-virtual-env.bat```. This will set-up a virtual environment to avoid messing with the global level Python installation. Any errors encountered in the set-up will appear in the output from this script so make sure to read it if there are problems. \n\n3. Once run you should be able to type ```behave``` and it will run the single sample test. This should open Firefox and navigate to Wikipedia. \n\n## Configuration ##\n\n### Changing the browser ###\n\nDepending on the browser you have installed you can change the browser the test uses to run by changing the config in ```~\\src\\Config.ini```:\n\t\n\t[selenium]\n\tdriver = Firefox\n\nThe possible values are currently:\n\n+ Firefox\n+ Chrome\n+ Internet Explorer\n\n### Changing cookie clearing behaviour ###\n\nThe project is set up to clear cookies from the browser session based on the setting in Config.ini\n\t\n\t[selenium]\n\tdriver = Chrome\n\tclear_cookies = lifetime\n\nThe possible values are:\n\n+ step - clears cookies after each individual step is run\n+ feature - clears cookies after all scenarios in a feature file are run\n+ lifetime - clears cookies only after an entire test run finishes\n+ scenario - clears cookies after each full Given/When/Then scenario\n\n### Using custom configuration ###\n\nYou can add your own settings to Config.ini and easily access them from your step definitions. For example, in Config.ini:\n\n\t[tests]\n\turl = http://wikipedia.org\n\nThen in steps/wikipedia.py:\n\n\tfrom helpers import configuration\n\t\n\t@when(\"I am on the homepage\")\n\tdef step_impl(context):\n    \t\tcontext.browser.get(configuration.get_setting(\"tests\", \"url\"))\n\n## Important Information ##\n\nThe driver in this template is created once per run. While it can be set to clear cookies after any tye of step this means the session will persist for all tests.\nIf your application uses the session you will need to start the driver on a per scenario basis. To achieve this you can move the code (in environment.py):\n\n    browsertype = configuration.get_browser()\n    context.browser = driver.switch_browser(browsertype)\n\t\nInto the ```def before_scenario(context, scenario): ``` function.\n\nYou will also need to move ```context.browser.quit()``` to the ```after_scenario``` function.\n\nDoing this will make performance considerably slower.\n\n## Known Problems ##\n\n### First Run ###\n\nOn the first run the test may fail due to browser configuration. For example you may need to grant Python access to the internet.\n\nInternet Explorer requires all Internet Zones to use the same Protected Mode (all on or off). Use ```Tools (cog image) \u003e Internet Options \u003e Security \u003e Enable Protected Mode``` to configure this.\n\nAdditionally Internet Explorer requires the zoom level to be set to 100%. Once the browser has been configured all subsequent runs should be successful.\n\n### Activate Virtual Environment ###\n\nIf when running ```behave``` from the command prompt you get the following message:\n\n\t'behave' is not recognized as an internal or external command,\n\toperable program or batch file.\n\nYou need to activate the Virtual Environment. From a command prompt:\n\n\tC:\\git\\UglyToad.Python.UITesting\u003eenv\\Scripts\\activate\n\nWhen the environment has been activated you will see the (env) label at the prompt:\n\n\t(env) C:\\git\\UglyToad.Python.UITesting\u003e\n\n## Use with CI ##\n\nThe intention is for this project to be used for continuous integration. \nI have included an example Jenkins configuration ~\\tools\\config.xml\n\n\n[link0]:http://pythonhosted.org/behave/index.html\n[link1]:https://www.python.org/downloads/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliotjones%2Fbehave-selenium-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliotjones%2Fbehave-selenium-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliotjones%2Fbehave-selenium-template/lists"}