Skip to content

Commit

Permalink
offline option added
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey committed Jan 21, 2017
1 parent 76dc240 commit 114e44d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from time import sleep

import pytest
from webdriver_manager import config

from webdriver_manager.cache import CacheManager
from webdriver_manager.config import Configuration
from webdriver_manager.driver import ChromeDriver, GeckoDriver

cache = CacheManager()
cache = CacheManager(to_folder=config.folder, dir_name=config.folder)


def delete_cache():
Expand Down Expand Up @@ -64,7 +65,7 @@ def test_should_be_true_for_cached_driver(os_type):


def test_should_be_false_for_new_driver():
version = "2.26"
version = "2.25"
driver = ChromeDriver(version=version,
os_type="win")
cache_path = cache.get_cache_path()
Expand All @@ -86,8 +87,7 @@ def test_cache_driver_version():


def test_cached_driver_manual_setup():
config = Configuration(config_folder=os.path.dirname(__file__), file_name="wd_config.ini")
config.default()
config = Configuration(config_folder=os.path.dirname(__file__), file_name="wd_config.ini", section="ChromeDriver")
version = "2.26"
os_type = "linux"
driver = ChromeDriver(version=version,
Expand Down
9 changes: 5 additions & 4 deletions tests/wd_config.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[DEFAULT]
driver_path = /home/

[GeckoDriver]
gh_token = test_token
driver_latest_release_url = test_release
driver_latest_release_url = test_release

[ChromeDriver]
offline = True
driver_path = /home/
3 changes: 2 additions & 1 deletion webdriver_manager/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def create_cache_dir(self, driver_path):

def get_cached_binary(self, driver):
cached_driver = driver.config.driver_path
if cached_driver:
is_offline = driver.config.offline
if cached_driver and is_offline == 'True':
logging.warning("Using driver from cache {}".format(cached_driver))
return Binary(cached_driver)

Expand Down
1 change: 1 addition & 0 deletions webdriver_manager/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
driver_path =
gh_token =
version = latest
offline = False

[GeckoDriver]
driver_latest_release_url = https://api.github.com/repos/mozilla/geckodriver/releases/latest
Expand Down

0 comments on commit 114e44d

Please sign in to comment.