Git Product home page Git Product logo

webdriver_manager's Introduction

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:

webdriver.Chrome('/home/user/drivers/chromedriver')

ChromeDriverManager(path=custom_path).install()

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

If you face error related to github credentials, you need to place github token: (*)

Example:

export GH_TOKEN = "asdasdasdasd"

(*) access_token required to work with Github API more info https://help.github.com/articles/creating-an-access-token-for-command-line-use/.

There is also possibility to set same variables via ENV VARIABLES.

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()

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()

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'

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!

webdriver_manager's People

Contributors

sergeypirogov avatar gospodinkot avatar aleksandr-kotlyar avatar maratori avatar s-weigand avatar arunabalasubramanian avatar markbrook avatar dependabot[bot] avatar rafiten90 avatar jhawgs avatar janringas avatar sam-goode avatar olegchursin avatar vanderloos avatar kjgoodrick avatar klemek avatar benquike avatar hhongseungwoo avatar damziobro avatar cgoldberg avatar quron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.