Revision 3611dd6a
Added by koszko over 1 year ago
| test/test_integration.py | ||
|---|---|---|
| 18 | 18 |
# CC0 1.0 Universal License for more details. |
| 19 | 19 |
|
| 20 | 20 |
import pytest |
| 21 |
import re |
|
| 22 | 21 |
|
| 23 |
from selenium.webdriver.support.ui import WebDriverWait |
|
| 24 |
from selenium.common.exceptions import NoSuchElementException |
|
| 25 |
|
|
| 26 |
extract_base_url_re = re.compile(r'^(.*)manifest.json$') |
|
| 27 |
|
|
| 28 |
def get_extension_base_url(driver): |
|
| 29 |
""" |
|
| 30 |
Extension's internall UUID is not directly exposed in Selenium. Instead, we |
|
| 31 |
can navigate to about:debugging and inspect the manifest URL present there |
|
| 32 |
to get the base url like: |
|
| 33 |
moz-extension://b225c78f-d108-4caa-8406-f38b37d8dee5/ |
|
| 34 |
which can then be used to navigate to extension-bundled pages. |
|
| 35 |
""" |
|
| 36 |
driver.implicitly_wait(10) |
|
| 37 |
try: |
|
| 38 |
# For newer Firefoxes |
|
| 39 |
driver.get('about:debugging#/runtime/this-firefox')
|
|
| 40 |
manifest_link = driver.find_element_by_class_name('qa-manifest-url')
|
|
| 41 |
except NoSuchElementException: |
|
| 42 |
driver.get("about:debugging#addons")
|
|
| 43 |
manifest_link = driver.find_element_by_class_name('manifest-url')
|
|
| 44 |
driver.implicitly_wait(0) |
|
| 45 |
|
|
| 46 |
manifest_url = manifest_link.get_attribute('href')
|
|
| 47 |
return extract_base_url_re.match(manifest_url).group(1) |
|
| 22 |
from .extension_crafting import get_extension_base_url |
|
| 48 | 23 |
|
| 49 | 24 |
@pytest.mark.usefixtures('haketilo')
|
| 50 | 25 |
def test_integration(driver): |
Also available in: Unified diff
facilitate running test environment with Haketilo loaded into browser