Skip to content

Commit c3660fb

Browse files
authored
fixing Firefox webdriver instantiation, closes #235 (#236)
* adding a failing mocked unit test * adding a fix
1 parent 7ee9dc8 commit c3660fb

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pylenium/webdriver_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def build_firefox(
275275
return webdriver.Firefox(
276276
executable_path=local_path, options=options, capabilities=caps, **(webdriver_kwargs or {})
277277
)
278-
return webdriver.Firefox(GeckoDriverManager(version=version).install(), options=options, **(webdriver_kwargs or {}))
278+
return webdriver.Firefox(executable_path=GeckoDriverManager(version=version).install(), options=options, **(webdriver_kwargs or {}))
279279

280280

281281
def build_ie(

tests/unit/test_bugfixes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from unittest.mock import patch, MagicMock
2+
from pylenium import webdriver_factory
3+
4+
5+
def test_235_webdriver_factory(tmpdir):
6+
file_to_use = tmpdir / "file"
7+
file_to_use.write("test")
8+
gecko_mock = MagicMock()
9+
gecko_mock.install.return_value = file_to_use
10+
with patch("pylenium.webdriver_factory.GeckoDriverManager", return_value=gecko_mock):
11+
with patch("pylenium.webdriver_factory.webdriver.firefox.webdriver.Service"):
12+
with patch("pylenium.webdriver_factory.webdriver.firefox.webdriver.RemoteWebDriver"):
13+
webdriver_factory.build_firefox("latest", ["headless"], {}, [], [], "", {})
14+
gecko_mock.install.assert_called_once()

0 commit comments

Comments
 (0)