From c699b6409e98fe64a70417a18b6e335b4c60f86d Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 13 Dec 2021 17:58:29 +0100 Subject: facilitate creating and installing WebExtensions during tests It is now possible to more conveniently test WebExtension APIs code by wrapping it into a test WebExtension and temporarily installing in the driven browser. --- test/unit/test_basic.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/unit/test_basic.py') diff --git a/test/unit/test_basic.py b/test/unit/test_basic.py index cbe5c8c..3b09cb6 100644 --- a/test/unit/test_basic.py +++ b/test/unit/test_basic.py @@ -26,8 +26,9 @@ def test_driver(driver): """ for proto in ['http://', 'https://']: driver.get(proto + 'gotmyowndoma.in') - element = driver.find_element_by_tag_name('title') - title = driver.execute_script('return arguments[0].innerText;', element) + title = driver.execute_script( + 'return document.getElementsByTagName("title")[0].innerText;' + ) assert "Schrodinger's Document" in title def test_script_loader(execute_in_page, load_into_page): @@ -39,3 +40,15 @@ def test_script_loader(execute_in_page, load_into_page): page='https://gotmyowndoma.in') assert execute_in_page('returnval(TYPE_PREFIX.VAR);') == '_' + +@pytest.mark.ext_data({}) +def test_webextension(driver, webextension): + """ + A trivial test case that verifies a test WebExtension created and installed + by the `webextension` fixture works and redirects specially-constructed URLs + to its test page. + """ + heading = driver.execute_script( + 'return document.getElementsByTagName("h1")[0].innerText;' + ) + assert "Extension's options page for testing" in heading -- cgit v1.2.3