Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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()
Esempio n. 10
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element.get_attribute(attribute) is not None, negate)
Esempio n. 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
Esempio n. 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()
Esempio n. 13
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(text in world.browser.html, negate)
Esempio n. 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)
Esempio n. 15
0
def should_see_a_link_to(step, negate, link):
    assert_with_negate(len(world.browser.find_link_by_href(link)) > 0, negate)
Esempio n. 16
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(world.browser.is_text_present(text), negate)
Esempio n. 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
Esempio n. 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)
Esempio n. 19
0
def should_see_in_the_page(step, negate, text):
    assert_with_negate(text in world.browser.html, negate)
Esempio n. 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
Esempio n. 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()
Esempio n. 22
0
def should_see_a_link_to(step, negate, link):
    assert_with_negate(len(world.browser.find_link_by_href(link)) > 0, negate)
Esempio n. 23
0
File: page.py Progetto: 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
Esempio n. 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)
Esempio n. 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()
Esempio n. 26
0
def contains_test(element, negate, *args):
    content = args[0]
    text = getattr(element, 'text', None)
    assert_with_negate(content in text, negate)
Esempio n. 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()
Esempio n. 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
Esempio n. 29
0
def should_see_a_link_called(step, negate, text):
    assert_with_negate(len(world.browser.find_link_by_text(text)) > 0, negate)
Esempio n. 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
Esempio n. 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)
Esempio n. 32
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element[attribute] != None, negate)
Esempio n. 33
0
def visibility_test(element, negate, *args):
    assert_with_negate(element, negate)
Esempio n. 34
0
 def assert_text_present_with_negates(negate, text):
     assert_with_negate(world.browser.is_text_present(text), negate)
     return True
Esempio n. 35
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element.get_attribute(attribute) is not None, negate)
Esempio n. 36
0
 def assert_link_exists_negates(negate, text):
     assert_with_negate(len(world.browser.find_link_by_href(text)) > 0, negate)
     return True
Esempio n. 37
0
def contains_test(element, negate, *args):
    content = args[0]
    text = getattr(element, 'text', None)
    assert_with_negate(content in text, negate)
Esempio n. 38
0
def attribute_test(element, negate, *args):
    attribute = args[0]
    assert_with_negate(element[attribute] != None, negate)
Esempio n. 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
Esempio n. 40
0
 def assert_text_present_with_negates(negate, text):
     assert_with_negate(world.browser.is_text_present(text), negate)
     return True
Esempio n. 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()
Esempio n. 42
0
 def assert_link_exists_negates(negate, text):
     assert_with_negate(len(world.browser.find_link_by_href(text)) > 0, negate)
     return True
Esempio n. 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()
Esempio n. 44
0
def visibility_test(element, negate, *args):
    assert_with_negate(element, negate)
Esempio n. 45
0
File: page.py Progetto: 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
Esempio n. 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()
Esempio n. 47
0
File: page.py Progetto: 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
Esempio n. 48
0
def should_see_a_link_called(step, negate, text):
    assert_with_negate(len(world.browser.find_link_by_text(text)) > 0, negate)