diff --git a/CHANGELOG.md b/CHANGELOG.md index 8551edfe..98e0bdf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,11 @@ --- ## 3.5.3 Determine browser versions on Windows ### Bugfixes -- Fixed logger for EdgeChromiumDriverManager and IEDriverManager (Resolves [#269](https://github.com/SergeyPirogov/webdriver_manager/issues/269), [#272](https://github.com/SergeyPirogov/webdriver_manager/issues/272)). +- Fixed logger for EdgeChromiumDriverManager and IEDriverManager ([#269](https://github.com/SergeyPirogov/webdriver_manager/issues/269), [#272](https://github.com/SergeyPirogov/webdriver_manager/issues/272)). +- Fixed `JSONDecodeError` when raising `ValueError` message of failed request. ([#273](https://github.com/SergeyPirogov/webdriver_manager/issues/273)). +- Fixed `geckodriver` permissions. When `webdriver.Firefox(GeckoDriverManager().install())` caused `os error 10061`. ### Features -- Determine browsers versions on Windows 32/64 bit by many ways. MSEdge, Chrome, Chromium, Firefox. PowerShell required. (Resolves [#261](https://github.com/SergeyPirogov/webdriver_manager/issues/261), [#193](https://github.com/SergeyPirogov/webdriver_manager/issues/193), [#293](https://github.com/SergeyPirogov/webdriver_manager/issues/293)). +- Determine browsers versions on Windows 32/64 bit by many ways. MSEdge, Chrome, Chromium, Firefox. PowerShell required. ([#261](https://github.com/SergeyPirogov/webdriver_manager/issues/261), [#193](https://github.com/SergeyPirogov/webdriver_manager/issues/193), [#293](https://github.com/SergeyPirogov/webdriver_manager/issues/293)). --- - ## 3.5.2 ### Features diff --git a/tests/test_edge_driver.py b/tests/test_edge_driver.py index 2dad09e8..0b1178e2 100644 --- a/tests/test_edge_driver.py +++ b/tests/test_edge_driver.py @@ -28,11 +28,10 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable): def test_edge_manager_with_wrong_version(): with pytest.raises(ValueError) as ex: - driver_path = EdgeChromiumDriverManager( + EdgeChromiumDriverManager( version="0.2", os_type='win64', ).install() - webdriver.Edge(executable_path=driver_path) assert ( "There is no such driver by url " diff --git a/tests/test_firefox_manager.py b/tests/test_firefox_manager.py index 0ee69ca3..5b72e2a3 100644 --- a/tests/test_firefox_manager.py +++ b/tests/test_firefox_manager.py @@ -26,8 +26,7 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable): def test_gecko_manager_with_wrong_version(): with pytest.raises(ValueError) as ex: - driver_path = GeckoDriverManager("0.2").install() - webdriver.Firefox(executable_path=driver_path) + GeckoDriverManager("0.2").install() assert "There is no such driver by url "\ "https://api.github.com/repos/mozilla/geckodriver/releases/tags/0.2" \ diff --git a/tests/test_opera_manager.py b/tests/test_opera_manager.py index c2c1dbb8..43604cce 100755 --- a/tests/test_opera_manager.py +++ b/tests/test_opera_manager.py @@ -49,8 +49,7 @@ def test_operadriver_manager_with_selenium(): def test_opera_driver_manager_with_wrong_version(): with pytest.raises(ValueError) as ex: - driver_path = OperaDriverManager("0.2").install() - webdriver.Opera(executable_path=driver_path) + OperaDriverManager("0.2").install() assert "There is no such driver by url " \ "https://api.github.com/repos/operasoftware/operachromiumdriver/" \ diff --git a/tests/test_utils.py b/tests/test_utils.py index 7a890fa8..7a06ce97 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,27 +1,41 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -from webdriver_manager import utils -from unittest import mock import pytest -import json +from requests import Response, Request + +from webdriver_manager import utils -def test_validate_response_json_decode_error(): - resp = mock.Mock() +def test_validate_response_value_error_not_200_and_not_404(): + resp = Response() resp.headers = {} - resp.request.url = "http://example.com" - resp.content = "content" - resp.json = mock.Mock(side_effect=json.decoder.JSONDecodeError("", "", 0)) + resp.request = Request() + resp.request.url = "https://example.com" + resp.status_code = 301 + resp._content = b"abc" + with pytest.raises(ValueError) as excinfo: utils.validate_response(resp) + assert str(excinfo.value) == "\n".join( [ "response body:", - "content", + "abc", "request url:", - "http://example.com", + "https://example.com", "response headers:", "{}", "" ] ) + + +def test_validate_response_value_error_404(): + resp = Response() + resp.request = Request() + resp.url = "https://example.com" + resp.status_code = 404 + + with pytest.raises(ValueError) as excinfo: + utils.validate_response(resp) + + expected_message = "There is no such driver by url https://example.com" + assert str(excinfo.value) == expected_message diff --git a/webdriver_manager/firefox.py b/webdriver_manager/firefox.py index c0cf80eb..d4167dd3 100644 --- a/webdriver_manager/firefox.py +++ b/webdriver_manager/firefox.py @@ -1,4 +1,5 @@ import logging +import os from webdriver_manager import utils from webdriver_manager.driver import GeckoDriver @@ -26,4 +27,7 @@ def __init__(self, version="latest", mozila_release_tag=mozila_release_tag) def install(self): - return self._get_driver_path(self.driver) + driver_path = self._get_driver_path(self.driver) + + os.chmod(driver_path, 0o755) + return driver_path