Skip to content

Commit 82f5998

Browse files
committed
Fixes and completes install_addon() tests on firefox
test_install_addon_directory() was being called with an xpi file fixture instead of a directory fixture. I fixed this by making a new fixture for test_install_addon_directory() that points to the test extension directory. See details here below. I also added an additional test and fixture so that the tests take into account whether a path to an extension directory ends with a trailing slash. See details here below. This required renaming the existing addon_path fixture to avoid confusion among the three related fixtures: - addon_path_xpi renamed fixture gives a path to the xpi file (was addon_path) updated test_install_add() and test_unistall_addon() - addon_path_dir new fixture that gives a path to the extension directory, ending without a '/' updated test_install_unsigned_addon_directory() to use it - addon_path_dir_slash (new fixture, and test) new fixture that gives a path to the extension directory, ending with a '/' added new test: test_install_unsigned_addon_directory_slash() Note that I don't have the appropriate environment to run these tests before pushing them.
1 parent a708f41 commit 82f5998

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

examples/python/tests/browsers/test_firefox.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,42 @@ def test_profile_location(temp_dir):
8888
driver.quit()
8989

9090

91-
def test_install_addon(firefox_driver, addon_path):
91+
def test_install_addon(firefox_driver, addon_path_xpi):
9292
driver = firefox_driver
9393

94-
driver.install_addon(addon_path)
94+
driver.install_addon(addon_path_xpi)
9595

9696
driver.get("https://www.selenium.dev/selenium/web/blank.html")
9797
injected = driver.find_element(webdriver.common.by.By.ID, "webextensions-selenium-example")
9898

9999
assert injected.text == "Content injected by webextensions-selenium-example"
100100

101101

102-
def test_uninstall_addon(firefox_driver, addon_path):
102+
def test_uninstall_addon(firefox_driver, addon_path_xpi):
103103
driver = firefox_driver
104104

105-
id = driver.install_addon(addon_path)
105+
id = driver.install_addon(addon_path_xpi)
106106
driver.uninstall_addon(id)
107107

108108
driver.get("https://www.selenium.dev/selenium/web/blank.html")
109109
assert len(driver.find_elements(webdriver.common.by.By.ID, "webextensions-selenium-example")) == 0
110110

111111

112-
def test_install_unsigned_addon_directory(firefox_driver, addon_path):
112+
def test_install_unsigned_addon_directory(firefox_driver, addon_path_dir):
113113
driver = firefox_driver
114114

115-
driver.install_addon(addon_path, temporary=True)
115+
driver.install_addon(addon_path_dir, temporary=True)
116+
117+
driver.get("https://www.selenium.dev/selenium/web/blank.html")
118+
injected = driver.find_element(webdriver.common.by.By.ID, "webextensions-selenium-example")
119+
120+
assert injected.text == "Content injected by webextensions-selenium-example"
121+
122+
123+
def test_install_unsigned_addon_directory_slash(firefox_driver, addon_path_dir_slash):
124+
driver = firefox_driver
125+
126+
driver.install_addon(addon_path_dir_slash, temporary=True)
116127

117128
driver.get("https://www.selenium.dev/selenium/web/blank.html")
118129
injected = driver.find_element(webdriver.common.by.By.ID, "webextensions-selenium-example")

examples/python/tests/conftest.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def log_path():
9494

9595

9696
@pytest.fixture(scope='function')
97-
def addon_path():
97+
def addon_path_xpi():
9898
if os.path.abspath("").endswith("tests"):
9999
path = os.path.abspath("extensions/webextensions-selenium-example.xpi")
100100
else:
@@ -103,6 +103,26 @@ def addon_path():
103103
yield path
104104

105105

106+
@pytest.fixture(scope='function')
107+
def addon_path_dir():
108+
if os.path.abspath("").endswith("tests"):
109+
path = os.path.abspath("extensions/webextensions-selenium-example")
110+
else:
111+
path = os.path.abspath("tests/extensions/webextensions-selenium-example")
112+
113+
yield path
114+
115+
116+
@pytest.fixture(scope='function')
117+
def addon_path_dir_slash():
118+
if os.path.abspath("").endswith("tests"):
119+
path = os.path.abspath("extensions/webextensions-selenium-example/")
120+
else:
121+
path = os.path.abspath("tests/extensions/webextensions-selenium-example/")
122+
123+
yield path
124+
125+
106126
@pytest.fixture(scope="function")
107127
def server_old(request):
108128
_host = "localhost"

0 commit comments

Comments
 (0)