Skip to main content

Library provides the way to automatically manage drivers for different browsers

Project description

Webdriver Manager for Python

Tests PyPI Supported Python Versions codecov

Patreon

The main idea is to simplify management of binary drivers for different browsers.

For now support:

  • ChromeDriver

  • GeckoDriver

  • IEDriver

  • OperaDriver

  • EdgeChromiumDriver

Before: You should download binary chromedriver, unzip it somewhere in you PC and set path to this driver like this:

from selenium import webdriver
driver = webdriver.Chrome('/home/user/drivers/chromedriver')

It’s boring!!! Moreover every time the new version of driver released, you should go and repeat all steps again and again.

With webdriver manager, you just need to do two simple steps:

Install manager:

pip install webdriver-manager

Use with Chrome:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

Use with Chromium:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType

driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())

Use with FireFox:

from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())

Use with IE

from selenium import webdriver
from webdriver_manager.microsoft import IEDriverManager

driver = webdriver.Ie(IEDriverManager().install())

Use with Edge

from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager

driver = webdriver.Edge(EdgeChromiumDriverManager().install())

Use with Opera

from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager

driver = webdriver.Opera(executable_path=OperaDriverManager().install())

If the Opera browser is installed in a location other than C:/Program Files or C:/Program Files (x86) on windows and /usr/bin/opera for all unix variants and mac, then use the below code,

from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager

options = webdriver.ChromeOptions()
options.add_argument('allow-elevated-browser')
options.binary_location = "C:\\Users\\USERNAME\\FOLDERLOCATION\\Opera\\VERSION\\opera.exe"
driver = webdriver.Opera(executable_path=OperaDriverManager().install(), options=options)

Configuration

webdriver_manager has several configuration variables you can be interested in.

GH_TOKEN

webdriver_manager downloading some webdrivers from their official GitHub repositories but GitHub has limitations like 60 requests per hour for unauthenticated users. In case not to face an error related to github credentials, you need to create github token and place it into your environment: (*)

Example:

# bash
export GH_TOKEN = "asdasdasdasd"

(*) access_token required to work with GitHub API more info.

There is also possibility to set same variable via ENV VARIABLES, example:

# python
import os
os.environ['GH_TOKEN'] = "asdasdasdasd"

WDM_LOG_LEVEL

To silent webdriver_manager logs and remove them from console, initialize env variable WDM_LOG_LEVEL with '0' value before your selenium tests:

import os

os.environ['WDM_LOG_LEVEL'] = '0'

or via constructor:

ChromeDriverManager("2.26", log_level=0).install()

WDM_PRINT_FIRST_LINE

By default webdriver manager prints a blank space before its log output if logging is enabled. If you want to disable this, initialize WDM_PRINT_FIRST_LINE with 'False' before your tests:

import os

os.environ['WDM_PRINT_FIRST_LINE'] = 'False'

or via constructor:

ChromeDriverManager("2.26", print_first_line=False).install()

WDM_LOCAL

By default all driver binaries are saved to user.home/.wdm folder. You can override this setting and save binaries to project.root/.wdm.

import os

os.environ['WDM_LOCAL'] = '1'

cache_valid_range

Driver cache by default is valid for 1 day. You are able to change this value using constructor parameter:

ChromeDriverManager("2.26", cache_valid_range=1).install()

This will make your test automation more elegant and robust!

Cheers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webdriver_manager-3.5.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

webdriver_manager-3.5.2-py2.py3-none-any.whl (17.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file webdriver_manager-3.5.2.tar.gz.

File metadata

  • Download URL: webdriver_manager-3.5.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for webdriver_manager-3.5.2.tar.gz
Algorithm Hash digest
SHA256 0a0df5e5d5d234702fd5948fec6c3884940aff904425725f15d8bb9eeaee18e8
MD5 8f7dd4fb997cae511338b27a8d95e49f
BLAKE2b-256 96b18276eb8b34dcbeb3fd1aadfd6341c3133b00f26f30e76559507ad2f6ef90

See more details on using hashes here.

File details

Details for the file webdriver_manager-3.5.2-py2.py3-none-any.whl.

File metadata

  • Download URL: webdriver_manager-3.5.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for webdriver_manager-3.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e3aa366b95b80b260bd71aea3a63ea3f19a6d14308e0cd93e1144ca46b11ef4
MD5 bad27c2698add562e539617c5f0ee9a5
BLAKE2b-256 74136ac33902d7c4dc012207876ef6e42d49a8b8202a6a83d69d139430249ed6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page