Exemplo n.º 1
0
def should_see_in_the_page(step, negate, text, wait_time):
    def assert_text_present_with_negates(negate, text):
        body = world.browser.driver.find_element_by_tag_name('body')
        assert_with_negate(text in body.text, negate)
        return True

    wait_for_completion(wait_time, assert_text_present_with_negates, negate,
                        text)
Exemplo n.º 2
0
def should_see_in_the_page(step, negate, text, wait_time):
    def assert_text_present_with_negates(negate, text):
        body = world.browser.driver.find_element_by_tag_name('body')
        assert_with_negate(text in body.text, negate)
        return True

    wait_for_completion(wait_time, assert_text_present_with_negates, negate,
                        text)
Exemplo n.º 3
0
def should_see_alert(step, negate, wait_time):
    def assert_alert(negate):
        world.prompt = _get_alert_or_none()
        assert_with_negate(world.prompt is not None, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert, negate)
Exemplo n.º 4
0
Arquivo: page.py Projeto: kiwnix/salad
def should_be_titled(step, negate, partial, title, wait_time):
    def assert_title_equals(negate, partial, title):
        if 'contains' in partial:
            assert_with_negate(title in world.browser.title, negate)
        else:
            assert_equals_with_negate(world.browser.title, title, negate)
        return True

    wait_for_completion(wait_time, assert_title_equals, negate, partial, title)
Exemplo n.º 5
0
def should_have_html(step, negate, partial, html, wait_time):
    def assert_page_html_is(negate, partial, html):
        if partial == 'is':
            assert_equals_with_negate(world.browser.html, html, negate)
        else:
            assert_with_negate(html in world.browser.html, negate)
        return True

    wait_for_completion(wait_time, assert_page_html_is, negate, partial, html)
Exemplo n.º 6
0
def should_have_the_url(step, negate, partial, url, wait_time):
    def assert_url_equals(negate, partial, url):
        if partial == 'is':
            assert_equals_with_negate(world.browser.url, url, negate)
        else:
            assert_with_negate(url in world.browser.url, negate)
        return True

    wait_for_completion(wait_time, assert_url_equals, negate, partial, url)
Exemplo n.º 7
0
def should_see_alert(step, negate, wait_time):
    def assert_alert(negate):
        world.prompt = _get_alert_or_none()
        assert_with_negate(world.prompt is not None, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert, negate)
Exemplo n.º 8
0
Arquivo: page.py Projeto: kiwnix/salad
def should_have_the_url(step, negate, partial, url, wait_time):
    def assert_url_equals(negate, partial, url):
        if partial == 'is':
            assert_equals_with_negate(world.browser.url, url, negate)
        else:
            assert_with_negate(url in world.browser.url, negate)
        return True

    wait_for_completion(wait_time, assert_url_equals, negate, partial, url)
Exemplo n.º 9
0
Arquivo: page.py Projeto: kiwnix/salad
def should_have_html(step, negate, partial, html, wait_time):
    def assert_page_html_is(negate, partial, html):
        if partial == 'is':
            assert_equals_with_negate(world.browser.html, html, negate)
        else:
            assert_with_negate(html in world.browser.html, negate)
        return True

    wait_for_completion(wait_time, assert_page_html_is, negate, partial, html)
Exemplo n.º 10
0
def should_be_titled(step, negate, partial, title, wait_time):
    def assert_title_equals(negate, partial, title):
        if 'contains' in partial:
            assert_with_negate(title in world.browser.title, negate)
        else:
            assert_equals_with_negate(world.browser.title, title, negate)
        return True

    wait_for_completion(wait_time, assert_title_equals, negate, partial, title)
Exemplo n.º 11
0
def _this_step(step, negate, attribute, element_name, type_of_match, value, wait_time):
    def assert_element_attribute_is_or_contains_text(
            negate, attribute, element_name,
            type_of_match, value):
        ele_value = _get_attribute_of_element(element_name, attribute)
        assert_value(type_of_match, value, ele_value, negate)
        return True
    wait_for_completion(
        wait_time, assert_element_attribute_is_or_contains_text,
        negate, attribute, element_name, type_of_match, value)
Exemplo n.º 12
0
def should_see_alert_with_text(step, negate, type_of_match, text, wait_time):
    def assert_alert_with_text(negate, type_of_match, text):
        world.prompt = _get_alert_or_none()
        prompt_exists = world.prompt is not None
        text_exists = None
        if "contains" in type_of_match:
            text_exists = text in world.prompt.text
        else:
            text_exists = world.prompt.text == text
        assert_with_negate(prompt_exists and text_exists, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert_with_text, negate, type_of_match, text)
Exemplo n.º 13
0
def should_see_alert_with_text(step, negate, type_of_match, text, wait_time):
    def assert_alert_with_text(negate, type_of_match, text):
        world.prompt = _get_alert_or_none()
        prompt_exists = world.prompt is not None
        text_exists = None
        if 'contains' in type_of_match:
            text_exists = text in world.prompt.text
        else:
            text_exists = world.prompt.text == text
        assert_with_negate(prompt_exists and text_exists, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert_with_text, negate,
                        type_of_match, text)
Exemplo n.º 14
0
def _this_step(step, negate, attribute, element_name, type_of_match, upper_lower, name, wait_time):
    def assert_element_attribute_is_or_contains_stored_value(
            negate, attribute, element_name, type_of_match,
            upper_lower, name):
        current = _get_attribute_of_element(element_name, attribute)
        stored = world.stored_values[name]
        if upper_lower:
            stored, current = transform_for_upper_lower_comparison(
                stored, current, upper_lower)
        assert_value(type_of_match, stored, current, negate)
        return True
    wait_for_completion(
        wait_time,
        assert_element_attribute_is_or_contains_stored_value, negate,
        attribute, element_name, type_of_match, upper_lower,
        name)
Exemplo n.º 15
0
def evaluate_the_javascript(step, negate, script, value, wait_time):
    def assert_javascript_returns_value(negate, script, value):
        try:
            assert_equals_with_negate(
                "%s" % world.browser.evaluate_script(script), value, negate)
        except NotImplementedError:
            logger.info("Attempted to run javascript in a javascript-disabled"
                        "browser. Moving along.")

        return True

    try:
        wait_for_completion(wait_time, assert_javascript_returns_value, negate,
                            script, value)
    except:
        ret_val = world.browser.evaluate_script(script)
        msg = "%s != %s after %s seconds" % (ret_val, value, wait_time)
        raise WrongJavascriptReturnValue(msg)
Exemplo n.º 16
0
def evaluate_the_javascript(step, negate, script, value, wait_time):
    def assert_javascript_returns_value(negate, script, value):
        try:
            assert_equals_with_negate(
                "%s" % world.browser.evaluate_script(script), value, negate)
        except NotImplementedError:
            logger.info("Attempted to run javascript in a javascript-disabled"
                        "browser. Moving along.")

        return True

    try:
        wait_for_completion(wait_time, assert_javascript_returns_value,
                            negate, script, value)
    except:
        ret_val = world.browser.evaluate_script(script)
        msg = "%s != %s after %s seconds" % (ret_val, value, wait_time)
        raise WrongJavascriptReturnValue(msg)
Exemplo n.º 17
0
def should_see_alert_with_stored_value(step, negate, type_of_match, upper_lower, name, wait_time):
    def assert_alert_with_stored_value(negate, type_of_match, upper_lower, name):
        world.prompt = _get_alert_or_none()
        assert world.stored_values[name]
        stored = world.stored_values[name]
        current = world.prompt.text
        if upper_lower:
            stored, current = transform_for_upper_lower_comparison(stored, current, upper_lower)
        prompt_exists = world.prompt is not None
        text_exists = None
        if "contains" in type_of_match:
            text_exists = stored in current
        else:
            text_exists = stored == current
        assert_with_negate(prompt_exists and text_exists, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert_with_stored_value, negate, type_of_match, upper_lower, name)
Exemplo n.º 18
0
def should_see_alert_with_stored_value(step, negate, type_of_match,
                                       upper_lower, name, wait_time):
    def assert_alert_with_stored_value(negate, type_of_match, upper_lower,
                                       name):
        world.prompt = _get_alert_or_none()
        assert world.stored_values[name]
        stored = world.stored_values[name]
        current = world.prompt.text
        if upper_lower:
            stored, current = transform_for_upper_lower_comparison(
                stored, current, upper_lower)
        prompt_exists = world.prompt is not None
        text_exists = None
        if 'contains' in type_of_match:
            text_exists = stored in current
        else:
            text_exists = stored == current
        assert_with_negate(prompt_exists and text_exists, negate)
        if world.prompt:
            world.prompt.accept()
        return True

    wait_for_completion(wait_time, assert_alert_with_stored_value, negate,
                        type_of_match, upper_lower, name)
Exemplo n.º 19
0
def should_be_in_page(step, negate, page, wait_time):
    def _assert_on_page():
        _check_is_on_page(page, negate)
        return True

    wait_for_completion(wait_time, _assert_on_page)
Exemplo n.º 20
0
def should_see_a_link_called(step, negate, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, None, "find_link_by_%stext")
Exemplo n.º 21
0
def should_see_a_link_to(step, negate, partial, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, partial, "find_by_%shref")
Exemplo n.º 22
0
def should_see_a_link_with_partial_text(step, negate, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, "partial", "find_link_by_%stext")
Exemplo n.º 23
0
def should_see_a_link_with_partial_text(step, negate, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, "partial", "find_link_by_%stext")
Exemplo n.º 24
0
def should_see_a_link_called(step, negate, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, None, "find_link_by_%stext")
Exemplo n.º 25
0
def should_see_a_link_to(step, negate, partial, text, wait_time):
    wait_for_completion(wait_time, assert_element_exists_with_negate, negate,
                        text, partial, "find_by_%shref")