def check_gone():
        # Select Serial Data Widget
        splinter_tests.select_by_text("type", "Serial Data Widget")

        with screenshot_on_exception("type_error_still_present"):
            assert not browser.is_text_present(
                "Invalid widget type selection.")
    def check_gone():
        # Select Serial Data Widget
        splinter_tests.select_by_text("type", "Serial Data Widget")

        with screenshot_on_exception("type_error_still_present"):
            assert not browser.is_text_present(
                "Invalid widget type selection.")
def is_error_message_present(key, message):
    xpath = ("//div[contains(@class, 'alert alert-danger')]/ul/li"
             "/strong[contains(., '{}')]/..").format(key)
    match = browser.find_by_xpath(xpath)

    # Check that we found a matching error message
    with screenshot_on_exception("find_error_%s" % key):
        assert not match.is_empty(), "No error message for %s" % key

        assert_that(match.first.text, contains_string(message))
def is_error_message_present(key, message):
    xpath = ("//div[contains(@class, 'alert alert-danger')]/ul/li"
             "/strong[contains(., '{}')]/..").format(key)
    match = browser.find_by_xpath(xpath)

    # Check that we found a matching error message
    with screenshot_on_exception("find_error_%s" % key):
        assert not match.is_empty(), "No error message for %s" % key

        assert_that(match.first.text, contains_string(message))
def test_configuration_modal_basic():
    '''The configuration modal should appear when the button is clicked.'''
    with screenshot_on_exception("config_modal_basic"):
        # Get the list of widget types, and their associated value in the
        # select tag.
        options = browser.find_by_css("select#type option")
        assert not options.is_empty()

        optmap = {}
        for opt in options:
            optmap[opt.text] = opt.value

        # Select switch widget
        browser.select("type", optmap['On/Off Switch Widget'])

        # Select the first gateway in the list
        browser.select("device", '0')

        # Wait for the discovery to complete. For the e2e server this should
        # only take a second or two
        do_sleep()

        # Pick the first XBee in the list
        browser.select('xbeenode', '0')

        # Pick the first stream option (DIO0)
        xpath = '//select[@id="sets"]//option[.="DIO0"]'
        # Copied from splinter browser.select implementation
        browser.find_by_xpath(xpath).first._element.click()

        # The button should be present now. But first, make sure the modal is
        # not present currently, to be safe.
        assert not browser.is_text_present("Device IO Configuration")

        button = browser.find_by_name("checkRadioConfig")
        assert not button.is_empty()
        button.first.click()

        # Check the modal appears
        assert browser.is_text_present("Device IO Configuration", wait_time=1)

        # Check that there is a close button
        xpath = '//div[@class="modal-footer"]/button[.="Close"]'
        btn = browser.find_by_xpath(xpath)
        assert not btn.is_empty()

        # Click the close button - does the modal go away?
        btn.first.click()
        # Wait a moment
        do_sleep()
        assert not browser.is_text_present("Device IO Configuration")
        assert browser.find_by_xpath(xpath).is_empty()
def test_configuration_modal_basic():
    '''The configuration modal should appear when the button is clicked.'''
    with screenshot_on_exception("config_modal_basic"):
        # Get the list of widget types, and their associated value in the
        # select tag.
        options = browser.find_by_css("select#type option")
        assert not options.is_empty()

        optmap = {}
        for opt in options:
            optmap[opt.text] = opt.value

        # Select switch widget
        browser.select("type", optmap['On/Off Switch Widget'])

        # Select the first gateway in the list
        browser.select("device", '0')

        # Wait for the discovery to complete. For the e2e server this should
        # only take a second or two
        do_sleep()

        # Pick the first XBee in the list
        browser.select('xbeenode', '0')

        # Pick the first stream option (DIO0)
        xpath = '//select[@id="sets"]//option[.="DIO0"]'
        # Copied from splinter browser.select implementation
        browser.find_by_xpath(xpath).first._element.click()

        # The button should be present now. But first, make sure the modal is
        # not present currently, to be safe.
        assert not browser.is_text_present("Device IO Configuration")

        button = browser.find_by_name("checkRadioConfig")
        assert not button.is_empty()
        button.first.click()

        # Check the modal appears
        assert browser.is_text_present("Device IO Configuration", wait_time=1)

        # Check that there is a close button
        xpath = '//div[@class="modal-footer"]/button[.="Close"]'
        btn = browser.find_by_xpath(xpath)
        assert not btn.is_empty()

        # Click the close button - does the modal go away?
        btn.first.click()
        # Wait a moment
        do_sleep()
        assert not browser.is_text_present("Device IO Configuration")
        assert browser.find_by_xpath(xpath).is_empty()
def log_in(*auth):
    delete_all_dashboards(*auth)
    add_empty_dashboard(*auth)

    log_in_clean(*auth)

    splinter_tests.visit("/#/add_widget")

    # Wait a moment for everything to settle
    do_sleep()

    with screenshot_on_exception("log_in_not_add_widget"):
        assert_that(browser.url, ends_with('/#/add_widget'))
def log_in(*auth):
    delete_all_dashboards(*auth)
    add_empty_dashboard(*auth)

    log_in_clean(*auth)

    splinter_tests.visit("/#/add_widget")

    # Wait a moment for everything to settle
    do_sleep()

    with screenshot_on_exception("log_in_not_add_widget"):
        assert_that(browser.url, ends_with('/#/add_widget'))
def re_login_no_devices():
    splinter_tests.visit("/logout")
    splinter_tests.visit("/#/login")

    do_sleep()

    with screenshot_on_exception("re_login_no_devices"):
        assert not browser.find_by_id("login_error").visible
        browser.fill("username", "e2e_user_nodevices")
        browser.fill("password", "e2e_password")
        browser.find_by_css('.btn.login-button').click()

        # Wait for a moment
        do_sleep()

        assert not browser.is_text_present(BAD_CREDS_TEXT)
        assert_that(browser.url, ends_with("#/setup"))
Пример #10
0
def re_login_no_devices():
    splinter_tests.visit("/logout")
    splinter_tests.visit("/#/login")

    do_sleep()

    with screenshot_on_exception("re_login_no_devices"):
        assert not browser.find_by_id("login_error").visible
        browser.fill("username", "e2e_user_nodevices")
        browser.fill("password", "e2e_password")
        browser.find_by_css('.btn.login-button').click()

        # Wait for a moment
        do_sleep()

        assert not browser.is_text_present(BAD_CREDS_TEXT)
        assert_that(browser.url, ends_with("#/setup"))
Пример #11
0
    def button_missing(missing=True):
        with screenshot_on_exception("button_missing_assert_%s" % missing):
            buttons = browser.find_by_xpath(button_xpath)

            assert_that(buttons.is_empty(), is_(missing))
    def button_missing(missing=True):
        with screenshot_on_exception("button_missing_assert_%s" % missing):
            buttons = browser.find_by_xpath(button_xpath)

            assert_that(buttons.is_empty(), is_(missing))