{"id":19056327,"url":"https://github.com/kottenator/pytest-browserstack-local","last_synced_at":"2026-05-11T16:30:25.102Z","repository":{"id":62584050,"uuid":"119626792","full_name":"kottenator/pytest-browserstack-local","owner":"kottenator","description":"py.test plugin to run BrowserStackLocal in background during the test session.","archived":false,"fork":false,"pushed_at":"2018-02-09T06:15:56.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-02T12:37:56.337Z","etag":null,"topics":["browserstack","browserstack-local","python"],"latest_commit_sha":null,"homepage":"","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/kottenator.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-31T03:02:20.000Z","updated_at":"2018-02-09T18:25:42.000Z","dependencies_parsed_at":"2022-11-03T20:19:38.292Z","dependency_job_id":null,"html_url":"https://github.com/kottenator/pytest-browserstack-local","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fpytest-browserstack-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fpytest-browserstack-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fpytest-browserstack-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kottenator%2Fpytest-browserstack-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kottenator","download_url":"https://codeload.github.com/kottenator/pytest-browserstack-local/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240112373,"owners_count":19749636,"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":["browserstack","browserstack-local","python"],"created_at":"2024-11-08T23:49:06.245Z","updated_at":"2026-05-11T16:30:25.026Z","avatar_url":"https://github.com/kottenator.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pytest-browserstack-local |travis-ci|\n=====================================\n\n.. |travis-ci| image:: https://travis-ci.org/kottenator/pytest-browserstack-local.svg?branch=develop\n               :target: https://travis-ci.org/kottenator/pytest-browserstack-local\n\n.. raw:: html\n\n    \u003cimg src=\"https://user-images.githubusercontent.com/371674/36011905-7c6e2530-0d28-11e8-9fe7-b4613c1ea942.png\" height=\"100px\"\u003e\n\n``py.test`` plugin to run ``BrowserStackLocal`` in background during the test session.\n\nInstall\n-------\n\n.. code-block :: bash\n\n    pip install pytest-browserstack-local\n\nUse\n---\n\nLet's assume you're using ``pytest-selenium`` with ``pytest-django``.\n\nIt's a good example because Django runs so-called ``LiveServer`` of your app on ``localhost``\nfor test purposes and that's a perfect reason why we need ``BrowserStackLocal``.\n\nBut it can be *anything else* which runs your app on ``localhost``.\n\nAlso let's assume that you have downloaded `BrowserStackLocal\n\u003chttps://www.browserstack.com/automate/python#setting-local-tunnel\u003e`_ and it's on your\n*system path* now (though there is an option to provide explicit path to the binary).\n\n.. code-block :: python\n\n    # tests/test_home_page.py\n\n    def test_home_page_title(selenium, live_server):\n        selenium.get(live_server.url)\n        assert selenium.title == \"Home page - My Django Project\"\n\nNow run your tests in BrowserStack:\n\n.. code-block :: bash\n\n    export BROWSERSTACK_USERNAME=\"\u003csecret-name\u003e\"   # used by ``pytest-selenium``\n    export BROWSERSTACK_ACCESS_KEY=\"\u003csecret-key\u003e\"  # used by ``pytest-selenium``\n                                                   # and by ``pytest-browserstack-local``\n    py.test tests/test_home_page.py \\\n        --driver BrowserStack \\\n        --capability os Windows \\\n        --capability os_version 10 \\\n        --capability browser IE \\\n        --capability browserstack.local True \\\n        --browserstack-local\n\nNote: there are two cases how you can run ``BrowserStackLocal`` - as a foreground process\nand as a daemon process. ``pytest-browserstack-local`` supports both but it's better to\nuse the latter one (because in the first case we're scanning the process output for a\nspecific text, which is a bit \"hacky\"):\n\n.. code-block :: bash\n\n    --browserstack-local-argument daemon=start\n\nCLI arguments\n-------------\n\n- ``--browserstack-local`` - enable ``pytest-browserstack-local`` plugin.\n  Without it - no other argument will take effect.\n- ``--browserstack-local-path`` - path to ``BrowserStackLocal`` binary.\n  Default: ``BrowserStackLocal`` in *system path*.\n- ``--browserstack-local-argument`` - pass an argument for ``BrowserStackLocal`` binary.\n  You can specify it multiple times. Pass it in any of the following formats:\n\n  - ``--browserstack-local-argument local-identifier=ABC123``\n  - ``--browserstack-local-argument localIdentifier=ABC123``\n\n  And for *boolean arguments* (aka \"flags\") use one of the following formats:\n\n  - ``--browserstack-local-argument only-automate``\n  - ``--browserstack-local-argument onlyAutomate``\n\n  No value must be presented!\n\n  See all the possible arguments in `BrowserStackLocal docs\n  \u003chttps://www.browserstack.com/local-testing#configuration\u003e`_\n  (or just do ``BrowserStackLocal --help``).\n\nEnvironment variables\n---------------------\n\n- ``BROWSERSTACK_ACCESS_KEY`` - access key for your BrowserStack account.\n\nConfiguration file\n------------------\n\n``pytest-browserstack-local`` plugin is integrated with ``pytest-variables``.\n\nYou can put all the ``BrowStackLocal`` arguments into a file\n(e.g. ``browserstack-local-config.json``):\n\n.. code-block ::\n\n    {\n      \"BrowserStackLocal\": {\n        \"key\": \"XYZ\",\n        \"proxyHost\": \"localhost\",\n        \"proxyPort\": \"12345\",\n        \"proxyUser\": \"admin\",\n        \"proxyPass\": \"12345\",\n        \"onlyAutomate\": true\n      }\n    }\n\nAnd then use it in CLI via ``pytest-variables``:\n\n.. code-block :: bash\n\n    py.test --variables browserstack-local-config.json\n\nYou can use any of the following formats for *keys* in the config file:\n\n- ``local-identifier``\n- ``localIdentifier``\n\nSee all the possible arguments in `BrowserStackLocal docs\n\u003chttps://www.browserstack.com/local-testing#configuration\u003e`_\n(or just do ``BrowserStackLocal --help``).\n\nFixtures\n--------\n\n- ``browserstack_local`` - a ``dict`` with the ``BrowserStackLocal`` process info.\n\n  There are two cases:\n\n  - Foreground process (e.g.):\n\n    .. code-block :: python\n\n        {\n            'process': subprocess.Popen(...),\n            'daemon': None,\n            'cmd': ['BrowserStackLocal', '--key', '\u003csecret-key\u003e']\n        }\n\n  - Daemon process (e.g.):\n\n    .. code-block :: python\n\n        {\n            'process': None,\n            'daemon': {\n                'state': 'connected',\n                'pid': 48213,\n                'message': 'Connected'\n            },\n            'cmd': ['BrowserStackLocal', '--key', '\u003csecret-key\u003e', '--daemon', 'start']\n        }\n\nDevelopment\n-----------\n\n- Make a fork (if you're not me).\n- Checkout the repo.\n- Create a virtualenv.\n- ``pip install -e '.[test]'``\n- Do your changes.\n- ``py.test``\n- Make a pull-request ;)\n\nI'm always open for great ideas, but even more - for contribution.\n\nRun a real test\n~~~~~~~~~~~~~~~\n\nIf you want to try it *for real*: download \u0026 install `BrowserStackLocal\n\u003chttps://www.browserstack.com/automate/python#setting-local-tunnel\u003e`_ and then run:\n\n.. code-block:: bash\n\n    export BROWSERSTACK_USERNAME=\"\u003csecret-name\u003e\"\n    export BROWSERSTACK_ACCESS_KEY=\"\u003csecret-key\u003e\"\n\n    py.test -m sensitive \\\n        --driver BrowserStack \\\n        --capability os Windows \\\n        --capability os_version 10 \\\n        --capability browser IE \\\n        --capability browserstack.local True \\\n        --browserstack-local \\\n        --browserstack-local-path ./BrowserStackLocal\n\nThis will run a *hidden* Selenium test that runs real ``BrowserStackLocal`` and checks\na ``localhost``-hosted page on BrowserStack.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkottenator%2Fpytest-browserstack-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkottenator%2Fpytest-browserstack-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkottenator%2Fpytest-browserstack-local/lists"}