Project

General

Profile

« Previous | Next » 

Revision 5ed09841

Added by koszko over 1 year ago

fix loading initial data and verify it in automated tests

View differences:

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 48

  
23 49
@pytest.mark.usefixtures('haketilo')
24 50
def test_integration(driver):
25
    #from time import sleep
26
    #sleep(100000)
51
    """
52
    Verify that the entire extension functions properly. Also verify bunlded
53
    default settings get loaded properly.
54
    """
55
    base_url = get_extension_base_url(driver)
56
    driver.get(base_url + 'html/settings.html')
57

  
58
    for tab_head_id, item_text in [
59
            ('resources_head', 'Haketilo demonstrational script'),
60
            ('mappings_head',  'Haketilo demonstrational message'),
61
    ]:
62
        driver.find_element_by_id(tab_head_id).click()
63
        lst = driver.find_element_by_css_selector('.active_tab .item_list')
64
        assert lst.is_displayed()
65
        assert item_text in lst.text
66

  
67
    driver.find_element_by_id('repos_head').click()
68
    lst = driver.find_element_by_css_selector('.active_tab .text_entries')
69
    assert 'https://hydrilla.koszko.org/api_v1' in lst.text
27 70

  
28
    # TODO!!!
29
    pass
71
    # TODO: do some more tests, including popup interaction and repository
72
    # querying

Also available in: Unified diff