{"id":16031745,"url":"https://github.com/vivint/selenium-docker","last_synced_at":"2025-08-13T03:14:51.763Z","repository":{"id":57465375,"uuid":"118019056","full_name":"vivint/selenium-docker","owner":"vivint","description":"Extending Selenium drivers with extra runtime goodies!","archived":false,"fork":false,"pushed_at":"2018-01-18T18:42:38.000Z","size":114,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-13T16:46:29.717Z","etag":null,"topics":["docker","gevent","selenium","selenium-python","web-scraping"],"latest_commit_sha":null,"homepage":"https://selenium-docker.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vivint.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":"2018-01-18T18:04:47.000Z","updated_at":"2020-06-19T18:29:38.000Z","dependencies_parsed_at":"2022-08-31T03:12:15.109Z","dependency_job_id":null,"html_url":"https://github.com/vivint/selenium-docker","commit_stats":null,"previous_names":["vivint/selenium-council"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivint%2Fselenium-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivint%2Fselenium-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivint%2Fselenium-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivint%2Fselenium-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivint","download_url":"https://codeload.github.com/vivint/selenium-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246080971,"owners_count":20720624,"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":["docker","gevent","selenium","selenium-python","web-scraping"],"created_at":"2024-10-08T21:05:17.610Z","updated_at":"2025-03-28T18:32:26.892Z","avatar_url":"https://github.com/vivint.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vivint-selenium-docker\n\n[![pypi](https://img.shields.io/pypi/v/selenium-docker.svg)]()\n[![Read the Docs](https://img.shields.io/readthedocs/selenium-docker.svg)](https://selenium-docker.readthedocs.io/en/latest/)\n[![License ALv2](https://img.shields.io/github/license/vivint/selenium-docker.svg)](https://github.com/vivint/selenium-docker/blob/master/LICENSE)\n\nExtending Selenium with drop in replacements for Chrome and Firefox webdrivers\nthat run in Docker containers. Additional goodies like automatic proxies, live\nvideo recording and driver-pools are included!\n\n## Getting Started\n\n1. Install the module:\n\n    Latest stable version from pypi,\n\n    ```bash\n    $ pip install selenium-docker\n    ```\n    \n    Development version from source,\n    \n    ```bash\n    $ pip install git+ssh://git@github.com:vivint/selenium-council.git\n    ```\n\n2. Download [docker](https://www.docker.com/get-docker) for your operating system and ensure it's running.\n\n    ```bash\n    $ docker version\n    Client:\n     Version:      17.10.0-ce\n     API version:  1.33\n    \n    Server:\n     Version:      17.10.0-ce\n     API version:  1.33 (minimum version 1.12)\n    ```\n\n3. \n\n#### You should know...\n\n- Calling `getLogger('selenium_docker').setLevel(logging.DEBUG)` during Logging setup will turn on lots of debug statements involved with with spawning and managing the underlying containers and driver instances.\n\n- You can use the script below to stop and remove all running containers created by this library:\n\n    ```python\n    from selenium_docker.base import ContainerFactory\n    \n    factory = ContainerFactory.get_default_factory()\n    factory.scrub_containers()\n    ```\n\n    This will do a search in the default Docker engine for all containers that use our `browser` and `dynamic` labels.\n\n- We use [`gevent`](http://www.gevent.org/contents.html) for its concurrency idioms. \n\n- We call `gevent.monkey.patch_socket` to communicate with Docker engine via REST. Other libraries may need to be patched contingent on what your project is trying to accomplish.\n  \n  Read about [monkey patching](http://www.gevent.org/intro.html#monkey-patching) on the gevent website.\n\n## Examples\n\n#### Basic\n\nCreates a single container with a running Chrome Driver instance inside. Connecting and managing the container is all done automatically. This should function as a drop in replacement for using the desktop version of Chrome and Firefox drivers.\n\n```python\nimport sys\nimport logging\n\nfrom selenium_docker import ChromeDriver\n\nlogging.basicConfig(stream=sys.stdout, level=logging.DEBUG)\nlogging.getLogger('selenium_docker').setLevel(logging.DEBUG)\n\ndriver = ChromeDriver()\n\ndriver.get('https://google.com')\n\nprint(driver.title)\n\ndriver.quit()\n```\n\n#### Blocking driver pool\n\nUsed for performing a single task on multiple sites/items in parallel. \n\nThe blocking driver pool will create all the necessary containers in advance in order to distribute the work as resources become available. Drivers will be reused  until the `.execute()` call is complete. If the driver throws an Exception then that driver will be removed from the pool.\n\n```python\nfrom selenium_docker.pool import DriverPool\n\n\ndef get_title(driver, url):\n    driver.get(url)\n    return driver.title\n\nurls = [\n    'https://google.com',\n    'https://reddit.com',\n    'https://yahoo.com',\n    'http://ksl.com',\n    'http://cnn.com'\n]\n\npool = DriverPool(size=3)\n\nfor result in pool.execute(get_title, urls):\n    print(result)\n```\n\n#### Asynchronous driver pool,\n\n```python\nfrom selenium_docker.pool import DriverPool\n\n\ndef get_title(driver, url):\n    driver.get(url)\n    return driver.title\n\ndef print_fn(s):\n    print(s)\n\nurls = [\n    'https://google.com',\n    'https://reddit.com',\n    'https://yahoo.com',\n    'http://ksl.com',\n    'http://cnn.com'\n]\n\n\npool = DriverPool(size=2)\npool.execute_async(get_title, urls, print_fn)\npool.add_async(['https://facebook.com',\n                'https://mail.com',\n                'https://outlook.com'])\n\nfor x in pool.results():\n    print('result - ', x)\n\n    if '.com' in x:\n        pool.add_async(['https://wikipedia.org'])\n\n    if x == 'Wikipedia':\n        pool.stop_async()\n        pool.factory.scrub_containers()\n```\n\n## License\n\nCopyright 2017 - Vivint, inc.\n\nApache V2 -- See `LICENSE` for full statement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivint%2Fselenium-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivint%2Fselenium-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivint%2Fselenium-docker/lists"}