Skip to content

Commit

Permalink
fixing Firefox webdriver instantiation, closes #235 (#236)
Browse files Browse the repository at this point in the history
* adding a failing mocked unit test

* adding a fix
  • Loading branch information
rusiniak committed Mar 20, 2022
1 parent 7ee9dc8 commit c3660fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pylenium/webdriver_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def build_firefox(
return webdriver.Firefox(
executable_path=local_path, options=options, capabilities=caps, **(webdriver_kwargs or {})
)
return webdriver.Firefox(GeckoDriverManager(version=version).install(), options=options, **(webdriver_kwargs or {}))
return webdriver.Firefox(executable_path=GeckoDriverManager(version=version).install(), options=options, **(webdriver_kwargs or {}))


def build_ie(
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_bugfixes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from unittest.mock import patch, MagicMock
from pylenium import webdriver_factory


def test_235_webdriver_factory(tmpdir):
file_to_use = tmpdir / "file"
file_to_use.write("test")
gecko_mock = MagicMock()
gecko_mock.install.return_value = file_to_use
with patch("pylenium.webdriver_factory.GeckoDriverManager", return_value=gecko_mock):
with patch("pylenium.webdriver_factory.webdriver.firefox.webdriver.Service"):
with patch("pylenium.webdriver_factory.webdriver.firefox.webdriver.RemoteWebDriver"):
webdriver_factory.build_firefox("latest", ["headless"], {}, [], [], "", {})
gecko_mock.install.assert_called_once()

2 comments on commit c3660fb

@nguyet0310
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still can't use Firefox browser, the error is below:
` with os.scandir(src) as itr:
E NotADirectoryError: [Errno 20] Not a directory: '.../.wdm/drivers/geckodriver/macos/v0.30.0/geckodriver'

/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/shutil.py:564: NotADirectoryError`
but in about folder, I already saw driver is downloaded:
image
and my config is below:
{
"driver": {
"browser": "firefox",
"remote_url": "",
"wait_time": 10,
"page_load_wait_time": 0,
"options": [],
"capabilities": {},
"version": "latest",
"experimental_options": null,
"extension_paths": [],
"webdriver_kwargs": {},
"local_path": ""
},
"logging": {
"screenshots_on": false
},
"viewport": {
"maximize": true,
"width": 1440,
"height": 900,
"orientation": "portrait"
}
}

@ElSnoMan
Copy link
Owner

@ElSnoMan ElSnoMan commented on c3660fb Mar 23, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.