Example #1
0
def assert_element_exists_with_negate(negate, text, partial, function):
    infix = "partial_" if partial else ""
    found = True
    try:
        _get_visible_element(function % (infix, ), None, text)
    except (ElementDoesNotExist, ElementIsNotVisible,
            ElementAtIndexDoesNotExist):
        found = False
    assert_with_negate(found, negate)
    return True
Example #2
0
def assert_element_exists_with_negate(negate, text, partial, function):
    infix = "partial_" if partial else ""
    found = True
    try:
        _get_visible_element(function % (infix, ), None, text)
    except (ElementDoesNotExist, ElementIsNotVisible,
            ElementAtIndexDoesNotExist):
        found = False
    assert_with_negate(found, negate)
    return True
Example #3
0
 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
Example #4
0
 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
Example #5
0
def _check_is_on_page(page, negate):
    if page not in leaf_world.available_pages:
        raise KeyError('"%s" page is undefined.' % page)

    if page not in leaf_world.pages:
        try:
            page_object = create_page_object(page)
        except KeyError:
            raise
    else:
        page_object = leaf_world.pages[page]

    is_on_page = page_object.is_current(world.browser.url, get_page_url(world.browser.url))

    assert_with_negate(is_on_page, negate)

    leaf_world.current_page = page_object
Example #6
0
 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
Example #7
0
 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
Example #8
0
 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
Example #9
0
def should_see_alert_with_text(step, negate, text):
    alert = _get_alert_or_none()
    assert_with_negate(alert is not None and alert.text == text, negate)
    if alert:
        alert.accept()
Example #10
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element.get_attribute(attribute) is not None, negate)
Example #11
0
 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
Example #12
0
def should_see_prompt(step, negate):
    world.prompt = _get_alert_or_none()
    assert_with_negate(world.prompt is not None, negate)
    if world.prompt:
        world.prompt.accept()
Example #13
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(text in world.browser.html, negate)
Example #14
0
 def _this_step(step, negate, first, last, find_pattern, content):
     ele = _get_element(finder_function, first, last, find_pattern)
     assert_with_negate(content in ele.text, negate)
Example #15
0
def should_see_a_link_to(step, negate, link):
    assert_with_negate(len(world.browser.find_link_by_href(link)) > 0, negate)
Example #16
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(world.browser.is_text_present(text), negate)
Example #17
0
 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
Example #18
0
 def _this_step(step, negate, first, last, find_pattern, attr_name):
     ele = _get_element(finder_function, first, last, find_pattern)
     assert_with_negate(ele[attr_name] != None, negate)
Example #19
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(text in world.browser.html, negate)
Example #20
0
 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
Example #21
0
def should_see_prompt_with_text(step, negate, text):
    world.prompt = _get_alert_or_none()
    assert_with_negate(world.prompt is not None and world.prompt.text == text,
                       negate)
    if world.prompt:
        world.prompt.accept()
Example #22
0
def should_see_a_link_to(step, negate, link):
    assert_with_negate(len(world.browser.find_link_by_href(link)) > 0, negate)
Example #23
0
File: page.py Project: kiwnix/salad
 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
Example #24
0
 def _this_step(step, negate, first, last, find_pattern, attr_name):
     ele = _get_element(finder_function, first, last, find_pattern)
     assert_with_negate(ele[attr_name] != None, negate)
Example #25
0
def should_see_alert_with_text(step, negate, text):
    alert = _get_alert_or_none()
    assert_with_negate(alert is not None and alert.text == text, negate)
    if alert:
        alert.accept()
Example #26
0
def contains_test(element, negate, *args):
    content = args[0]
    text = getattr(element, 'text', None)
    assert_with_negate(content in text, negate)
Example #27
0
def should_see_prompt_with_text(step, negate, text):
    world.prompt = _get_alert_or_none()
    assert_with_negate(world.prompt is not None and world.prompt.text == text, negate)
    if world.prompt:
        world.prompt.accept()
Example #28
0
 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
Example #29
0
def should_see_a_link_called(step, negate, text):
    assert_with_negate(len(world.browser.find_link_by_text(text)) > 0, negate)
Example #30
0
 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
Example #31
0
 def _this_step(step, negate, first, last, find_pattern, content):
     ele = _get_element(finder_function, first, last, find_pattern)
     assert_with_negate(content in ele.text, negate)
Example #32
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element[attribute] != None, negate)
Example #33
0
def visibility_test(element, negate, *args):
    assert_with_negate(element, negate)
Example #34
0
 def assert_text_present_with_negates(negate, text):
     assert_with_negate(world.browser.is_text_present(text), negate)
     return True
Example #35
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element.get_attribute(attribute) is not None, negate)
Example #36
0
 def assert_link_exists_negates(negate, text):
     assert_with_negate(len(world.browser.find_link_by_href(text)) > 0, negate)
     return True
Example #37
0
def contains_test(element, negate, *args):
    content = args[0]
    text = getattr(element, 'text', None)
    assert_with_negate(content in text, negate)
Example #38
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element[attribute] != None, negate)
Example #39
0
 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
Example #40
0
 def assert_text_present_with_negates(negate, text):
     assert_with_negate(world.browser.is_text_present(text), negate)
     return True
Example #41
0
def should_see_alert(step, negate):
    alert = _get_alert_or_none()
    assert_with_negate(alert is not None, negate)
    if alert:
        alert.accept()
Example #42
0
 def assert_link_exists_negates(negate, text):
     assert_with_negate(len(world.browser.find_link_by_href(text)) > 0, negate)
     return True
Example #43
0
def should_see_prompt(step, negate):
    world.prompt = _get_alert_or_none()
    assert_with_negate(world.prompt is not None, negate)
    if world.prompt:
        world.prompt.accept()
Example #44
0
def visibility_test(element, negate, *args):
    assert_with_negate(element, negate)
Example #45
0
File: page.py Project: kiwnix/salad
 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
Example #46
0
def should_see_alert(step, negate):
    alert = _get_alert_or_none()
    assert_with_negate(alert is not None, negate)
    if alert:
        alert.accept()
Example #47
0
File: page.py Project: kiwnix/salad
 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
Example #48
0
def should_see_a_link_called(step, negate, text):
    assert_with_negate(len(world.browser.find_link_by_text(text)) > 0, negate)