Skip to content

Commit

Permalink
chmod geckodriver path to give permissions;
Browse files Browse the repository at this point in the history
- fix test utils
- update CHANGELOG.md with SergeyPirogov#273
  • Loading branch information
aleksandr-kotlyar committed Feb 7, 2022
1 parent cf47f16 commit 1023497
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/test_edge_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
3 changes: 1 addition & 2 deletions tests/test_firefox_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
3 changes: 1 addition & 2 deletions tests/test_opera_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/" \
Expand Down
38 changes: 26 additions & 12 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion webdriver_manager/firefox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os

from webdriver_manager import utils
from webdriver_manager.driver import GeckoDriver
Expand Down Expand Up @@ -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

0 comments on commit 1023497

Please sign in to comment.