# open-webdriver
## The simplest and easiest way to get a scriptable chrome browser running using selenium webdriver.
Note that this package uses a pinned dependency for urllib3 and should be installed in an isolated environment.
# API
```bash
python -m pip install open-webdriver
```
```python
import os
from open_webdriver import open_webdriver
# Needed or else exceptions will be thrown when executed from github actions.
IS_HEADLESS = os.environ.get("GITHUB_ACTIONS") == "true"
def main():
with open_webdriver(headless=IS_HEADLESS) as driver:
driver.set_window_size(1440, 900) # Needed for headless mode.
# All Chromium / web driver dependencies are now installed.
driver.get("https://www.google.com")
assert driver.title == "Google"
if __name__ == "__main__":
main()
```
#### Platform Unit Tests
[![Actions Status](https://github.com/zackees/open-webdriver/workflows/MacOS_Tests/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_macos.yml)
[![Win_Tests](https://github.com/zackees/open-webdriver/actions/workflows/test_win.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_win.yml)
[![Ubuntu_Tests](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu.yml)
#### Platform binary nuitka build
[![MacOS_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_macos_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_macos_nuitka.yml)
[![Win_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_win_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_win_nuitka.yml)
[![Ubuntu_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_nuitka.yml)
#### Ubuntu Install Tests
[![Ubuntu_Test_Install](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_install.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_install.yml)
# Versions
Mac/Windows/Linux all use chromium version 101.0.4951.41
The user agent string will always indicate a Windows client, unless overriden.
# About
Yet another selenium webdriver wrapper API in python, with the aims of being the easist to use with only two lines of code to get running.
Unlike other selenium web driver wrappers, this one **has tests for Windows10/MacOS/Ubuntu platforms**.
One function is provided, `open_webdriver(...)` which takes care of downloading, installing and then running selenium.
Additionally, sane defaults are set, such as headless by default and ssl certs turned off. This code is also tested and examples are provided for use with the nuitka cross compiler, which allows you to create an binary executable. This is great for distributing a compiled binary
for Windows/MacOS/Ubuntu of your selenium bot with all original source code removed, making it impossible to reverse engineer.
`open-webdriver` is built on top of webdriver-manager https://pypi.org/project/webdriver-manager/ library, but with the following changes/fixes:
```python
os.environ['WDM_SSL_VERIFY'] = '0'
```
And other sensible platform specific fixes are applied in order for the selenium driver stack to pass the test suite.
Additionally, a versioned chromium binary is downloaded for Linux & Windows, while whatever Chrome system is used for Mac, due to app signing requirements.
When your app is launched, there will be a side folder name `.wdm` which contain the download of the webdriver used and brawser used. The disk cache for the driver is set for 7 day, after which it will be checked for a new version.
Benefits:
* Production ready. Cross platform tests.
* ssl certs are turned off to reduce errors for many websites.
* Downloading the proper binary for your platform and stashing it next to the app.
* Headless by default.
* Intelligently forces headless in a linux environment without a display card (prevents crash).
* Platform tests to ensure a stable cross platform experience.
* Pins to a specific version of selenium driver stack to ensure reproducable behavior.
* Nuitka Binary Builds for all platforms are tested.
Downsides:
* Only chrome is supported right now.
# Tests
#### Dev:
Just simply run `tox` at the command line and everything should be tested. You may need to install `tox` with `python -m pip tox`.
#### Package Test:
Run `open_webdriver_test` for package tests. This is useful if you are on a server and want to figure out if open_webdriver will be able to be run in
headless mode using the `chrome` driver.
# Docker
Please see `Dockerfile` for requirements for including `open_webdriver` in your Docker app.
Docker is supported in this build. Please see the `Dockerfile` and `docker-compose.yml` for bringup instructions. Simply use `docker-compose up` and then ssh into the docker instance and run `open_webdriver_test` and verify that the test completes normally.
# Nuitka
This package supports the Nuitka cross compiler to binary app. However to make this work YOU MUST include the package data for selenium or you will get errors about missing javascript files when the program loads. To get around this you'll need to add package data:
`python -m nuitka --include-package-data=selenium ...`
For example see the example build file:
[https://github.com/zackees/open-webdriver/blob/main/open_webdriver/tests/nuitka/test_binary_build.py](https://github.com/zackees/open-webdriver/blob/main/open_webdriver/tests/nuitka/test_binary_build.py)
# Pull Requests
Pull requests are welcome for this code base. When you submit your pull request you will need to have the following:
* New code must have a unit/test.
* Must pass the linting requirements. Run `tox` (also run on your pull request).
# Changes
* 1.5.0: Upgraded dependencies. No longer depends on ancient version of urllib.
* 1.4.5: `Driver` returned from `open_webdriver` is now of WebDriver type instead of one of the base classes. Should help linting.
* 1.4.4: Fixed nuitka build process with breaking dependencies introduced by python-dotenv 1.0.1
* 1.4.3: Updated nuitka package and fixed breaking build from urllib3 update.
* 1.4.2: Prints log if chrome driver fails to launch.
* 1.4.1: Try and fix failed upload on last version.
* 1.4.0: Adds default user agent string, fixes running headless mode which uses a different user agent string.
* 1.3.6: Remove mac m1 runner, which doesn't exist on github
* 1.3.5: Fixes macOS builds, now uses versioned macOS Chromium.
* 1.3.4: Fixes nuitka builds that broke with panda's update. Nuitka updated from 0.7.7->1.2.2
* 1.3.3: Adds user_agent.
* 1.3.2: Adds disable_dev_shm_usage.
* 1.3.1: Adds disable gpu.
* 1.3.0: Concurrent support added for open_webdriver() using a lockfile.
* 1.2.9: Sets downloaded chromedriver version to 101.0.4951.41
* 1.2.8: Docker support has been added.
* 1.2.3: Fix bug in 7za unarchiver path.
* 1.2.2: 7za unarchiver is now included.
* 1.2.1: Bug fixes and other improvements that easy deployment.
* 1.2.0: All platforms supported now. Linux / Win32 now downloads a chromioum browser. Firefox has been removed.
* 1.1.14: Fixes bugs for `open_webdriver_test` cmd
* 1.1.10: Adds package test `open_webdriver_test` cmd
* 1.1.9: Moves tests into package to allow running tests from package.
* 1.1.8: Minor fixes
* 1.1.7: Nit readme.
* 1.1.6: Fixes failing win-tox tests due to missing "PROGRAMW6432" value in os.environ (?!). Brave browser removed as it actually didn't work.
* 1.1.5: Cert warnings now suppressable with non headless sessions.
* 1.1.3: Suppress more cert warnings.
* 1.1.2: Suppress certificate warnings.
* 1.1.1: Update readme.
* 1.1.0: Platform binary builds using nuitka are now tested.
* 1.0.4: Now pins dependencies.
* 1.0.0: Initial code submit.
Raw data
{
"_id": null,
"home_page": "https://github.com/zackees/open-webdriver",
"name": "open-webdriver",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6.0",
"maintainer_email": null,
"keywords": null,
"author": "Zach Vorhies",
"author_email": "dont@email.me",
"download_url": "https://files.pythonhosted.org/packages/bf/cb/da7e196ef099694a7eceb8a9bd3bc0dbae9fa6f645bb20cf50ca8341a1f8/open_webdriver-1.5.0.tar.gz",
"platform": null,
"description": "# open-webdriver\r\n\r\n## The simplest and easiest way to get a scriptable chrome browser running using selenium webdriver.\r\n\r\nNote that this package uses a pinned dependency for urllib3 and should be installed in an isolated environment.\r\n\r\n# API\r\n\r\n```bash\r\npython -m pip install open-webdriver\r\n```\r\n\r\n```python\r\nimport os\r\nfrom open_webdriver import open_webdriver\r\n# Needed or else exceptions will be thrown when executed from github actions.\r\nIS_HEADLESS = os.environ.get(\"GITHUB_ACTIONS\") == \"true\"\r\n\r\ndef main():\r\n with open_webdriver(headless=IS_HEADLESS) as driver:\r\n driver.set_window_size(1440, 900) # Needed for headless mode.\r\n # All Chromium / web driver dependencies are now installed.\r\n driver.get(\"https://www.google.com\")\r\n assert driver.title == \"Google\"\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\n#### Platform Unit Tests\r\n[![Actions Status](https://github.com/zackees/open-webdriver/workflows/MacOS_Tests/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_macos.yml)\r\n[![Win_Tests](https://github.com/zackees/open-webdriver/actions/workflows/test_win.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_win.yml)\r\n[![Ubuntu_Tests](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu.yml)\r\n\r\n#### Platform binary nuitka build\r\n[![MacOS_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_macos_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_macos_nuitka.yml)\r\n[![Win_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_win_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_win_nuitka.yml)\r\n[![Ubuntu_Nuitka](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_nuitka.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_nuitka.yml)\r\n\r\n#### Ubuntu Install Tests\r\n[![Ubuntu_Test_Install](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_install.yml/badge.svg)](https://github.com/zackees/open-webdriver/actions/workflows/test_ubuntu_install.yml)\r\n\r\n\r\n# Versions\r\n\r\nMac/Windows/Linux all use chromium version 101.0.4951.41\r\nThe user agent string will always indicate a Windows client, unless overriden.\r\n\r\n# About\r\n\r\nYet another selenium webdriver wrapper API in python, with the aims of being the easist to use with only two lines of code to get running.\r\n\r\nUnlike other selenium web driver wrappers, this one **has tests for Windows10/MacOS/Ubuntu platforms**.\r\n\r\nOne function is provided, `open_webdriver(...)` which takes care of downloading, installing and then running selenium.\r\n\r\nAdditionally, sane defaults are set, such as headless by default and ssl certs turned off. This code is also tested and examples are provided for use with the nuitka cross compiler, which allows you to create an binary executable. This is great for distributing a compiled binary\r\nfor Windows/MacOS/Ubuntu of your selenium bot with all original source code removed, making it impossible to reverse engineer.\r\n\r\n\r\n`open-webdriver` is built on top of webdriver-manager https://pypi.org/project/webdriver-manager/ library, but with the following changes/fixes:\r\n```python\r\nos.environ['WDM_SSL_VERIFY'] = '0'\r\n```\r\n\r\nAnd other sensible platform specific fixes are applied in order for the selenium driver stack to pass the test suite.\r\n\r\nAdditionally, a versioned chromium binary is downloaded for Linux & Windows, while whatever Chrome system is used for Mac, due to app signing requirements.\r\n\r\nWhen your app is launched, there will be a side folder name `.wdm` which contain the download of the webdriver used and brawser used. The disk cache for the driver is set for 7 day, after which it will be checked for a new version.\r\n\r\nBenefits:\r\n\r\n * Production ready. Cross platform tests.\r\n * ssl certs are turned off to reduce errors for many websites.\r\n * Downloading the proper binary for your platform and stashing it next to the app.\r\n * Headless by default.\r\n * Intelligently forces headless in a linux environment without a display card (prevents crash).\r\n * Platform tests to ensure a stable cross platform experience.\r\n * Pins to a specific version of selenium driver stack to ensure reproducable behavior.\r\n * Nuitka Binary Builds for all platforms are tested.\r\n\r\nDownsides:\r\n\r\n * Only chrome is supported right now.\r\n\r\n\r\n# Tests\r\n\r\n#### Dev:\r\n\r\nJust simply run `tox` at the command line and everything should be tested. You may need to install `tox` with `python -m pip tox`.\r\n\r\n#### Package Test:\r\n\r\nRun `open_webdriver_test` for package tests. This is useful if you are on a server and want to figure out if open_webdriver will be able to be run in\r\nheadless mode using the `chrome` driver.\r\n\r\n# Docker\r\n\r\nPlease see `Dockerfile` for requirements for including `open_webdriver` in your Docker app.\r\n\r\nDocker is supported in this build. Please see the `Dockerfile` and `docker-compose.yml` for bringup instructions. Simply use `docker-compose up` and then ssh into the docker instance and run `open_webdriver_test` and verify that the test completes normally.\r\n\r\n# Nuitka\r\n\r\nThis package supports the Nuitka cross compiler to binary app. However to make this work YOU MUST include the package data for selenium or you will get errors about missing javascript files when the program loads. To get around this you'll need to add package data:\r\n\r\n`python -m nuitka --include-package-data=selenium ...`\r\n\r\nFor example see the example build file:\r\n[https://github.com/zackees/open-webdriver/blob/main/open_webdriver/tests/nuitka/test_binary_build.py](https://github.com/zackees/open-webdriver/blob/main/open_webdriver/tests/nuitka/test_binary_build.py)\r\n\r\n# Pull Requests\r\n\r\n\r\nPull requests are welcome for this code base. When you submit your pull request you will need to have the following:\r\n * New code must have a unit/test.\r\n * Must pass the linting requirements. Run `tox` (also run on your pull request).\r\n\r\n# Changes\r\n * 1.5.0: Upgraded dependencies. No longer depends on ancient version of urllib.\r\n * 1.4.5: `Driver` returned from `open_webdriver` is now of WebDriver type instead of one of the base classes. Should help linting.\r\n * 1.4.4: Fixed nuitka build process with breaking dependencies introduced by python-dotenv 1.0.1\r\n * 1.4.3: Updated nuitka package and fixed breaking build from urllib3 update.\r\n * 1.4.2: Prints log if chrome driver fails to launch.\r\n * 1.4.1: Try and fix failed upload on last version.\r\n * 1.4.0: Adds default user agent string, fixes running headless mode which uses a different user agent string.\r\n * 1.3.6: Remove mac m1 runner, which doesn't exist on github\r\n * 1.3.5: Fixes macOS builds, now uses versioned macOS Chromium.\r\n * 1.3.4: Fixes nuitka builds that broke with panda's update. Nuitka updated from 0.7.7->1.2.2\r\n * 1.3.3: Adds user_agent.\r\n * 1.3.2: Adds disable_dev_shm_usage.\r\n * 1.3.1: Adds disable gpu.\r\n * 1.3.0: Concurrent support added for open_webdriver() using a lockfile.\r\n * 1.2.9: Sets downloaded chromedriver version to 101.0.4951.41\r\n * 1.2.8: Docker support has been added.\r\n * 1.2.3: Fix bug in 7za unarchiver path.\r\n * 1.2.2: 7za unarchiver is now included.\r\n * 1.2.1: Bug fixes and other improvements that easy deployment.\r\n * 1.2.0: All platforms supported now. Linux / Win32 now downloads a chromioum browser. Firefox has been removed.\r\n * 1.1.14: Fixes bugs for `open_webdriver_test` cmd\r\n * 1.1.10: Adds package test `open_webdriver_test` cmd\r\n * 1.1.9: Moves tests into package to allow running tests from package.\r\n * 1.1.8: Minor fixes\r\n * 1.1.7: Nit readme.\r\n * 1.1.6: Fixes failing win-tox tests due to missing \"PROGRAMW6432\" value in os.environ (?!). Brave browser removed as it actually didn't work.\r\n * 1.1.5: Cert warnings now suppressable with non headless sessions.\r\n * 1.1.3: Suppress more cert warnings.\r\n * 1.1.2: Suppress certificate warnings.\r\n * 1.1.1: Update readme.\r\n * 1.1.0: Platform binary builds using nuitka are now tested.\r\n * 1.0.4: Now pins dependencies.\r\n * 1.0.0: Initial code submit.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Easiest zero-config selenium webdriver for Python",
"version": "1.5.0",
"project_urls": {
"Homepage": "https://github.com/zackees/open-webdriver"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a1aabf415a131b9ebdd3ce1b35c36f0c606a26a8d8ff50bbfb0781babeedbf16",
"md5": "c9a962ee609763c3436151ff69e574c2",
"sha256": "2e336f028750fe54d9994538eed29734c56df96e49bea781732dd4c3fb5ff816"
},
"downloads": -1,
"filename": "open_webdriver-1.5.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "c9a962ee609763c3436151ff69e574c2",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6.0",
"size": 11613,
"upload_time": "2024-04-24T22:39:59",
"upload_time_iso_8601": "2024-04-24T22:39:59.849217Z",
"url": "https://files.pythonhosted.org/packages/a1/aa/bf415a131b9ebdd3ce1b35c36f0c606a26a8d8ff50bbfb0781babeedbf16/open_webdriver-1.5.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bfcbda7e196ef099694a7eceb8a9bd3bc0dbae9fa6f645bb20cf50ca8341a1f8",
"md5": "1879e69a7141fa6bba18e4682da72658",
"sha256": "83529408571428c0e88f1a7ae5aec05016d51e23d1c83a6a68291ca186118241"
},
"downloads": -1,
"filename": "open_webdriver-1.5.0.tar.gz",
"has_sig": false,
"md5_digest": "1879e69a7141fa6bba18e4682da72658",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6.0",
"size": 13908,
"upload_time": "2024-04-24T22:40:02",
"upload_time_iso_8601": "2024-04-24T22:40:02.582508Z",
"url": "https://files.pythonhosted.org/packages/bf/cb/da7e196ef099694a7eceb8a9bd3bc0dbae9fa6f645bb20cf50ca8341a1f8/open_webdriver-1.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-24 22:40:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zackees",
"github_project": "open-webdriver",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "webdriver-manager",
"specs": [
[
"==",
"4.0.1"
]
]
},
{
"name": "selenium",
"specs": [
[
"==",
"4.20.0"
]
]
},
{
"name": "download",
"specs": []
},
{
"name": "filelock",
"specs": []
},
{
"name": "py7zr",
"specs": [
[
"==",
"0.20.2"
]
]
},
{
"name": "certifi",
"specs": []
},
{
"name": "six",
"specs": []
}
],
"tox": true,
"lcname": "open-webdriver"
}