Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions examples/python/tests/browsers/test_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,42 @@ def test_profile_location(temp_dir):
driver.quit()


def test_install_addon(firefox_driver, addon_path):
def test_install_addon(firefox_driver, addon_path_xpi):
driver = firefox_driver

driver.install_addon(addon_path)
driver.install_addon(addon_path_xpi)

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

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


def test_uninstall_addon(firefox_driver, addon_path):
def test_uninstall_addon(firefox_driver, addon_path_xpi):
driver = firefox_driver

id = driver.install_addon(addon_path)
id = driver.install_addon(addon_path_xpi)
driver.uninstall_addon(id)

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


def test_install_unsigned_addon_directory(firefox_driver, addon_path):
def test_install_unsigned_addon_directory(firefox_driver, addon_path_dir):
driver = firefox_driver

driver.install_addon(addon_path, temporary=True)
driver.install_addon(addon_path_dir, temporary=True)

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

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


def test_install_unsigned_addon_directory_slash(firefox_driver, addon_path_dir_slash):
driver = firefox_driver

driver.install_addon(addon_path_dir_slash, temporary=True)

driver.get("https://www.selenium.dev/selenium/web/blank.html")
injected = driver.find_element(webdriver.common.by.By.ID, "webextensions-selenium-example")
Expand Down
22 changes: 21 additions & 1 deletion examples/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def log_path():


@pytest.fixture(scope='function')
def addon_path():
def addon_path_xpi():
if os.path.abspath("").endswith("tests"):
path = os.path.abspath("extensions/webextensions-selenium-example.xpi")
else:
Expand All @@ -103,6 +103,26 @@ def addon_path():
yield path


@pytest.fixture(scope='function')
def addon_path_dir():
if os.path.abspath("").endswith("tests"):
path = os.path.abspath("extensions/webextensions-selenium-example")
else:
path = os.path.abspath("tests/extensions/webextensions-selenium-example")

yield path


@pytest.fixture(scope='function')
def addon_path_dir_slash():
if os.path.abspath("").endswith("tests"):
path = os.path.abspath("extensions/webextensions-selenium-example/")
else:
path = os.path.abspath("tests/extensions/webextensions-selenium-example/")

yield path


@pytest.fixture(scope="function")
def server_old(request):
_host = "localhost"
Expand Down