コード例 #1
0
ファイル: __init__.py プロジェクト: jricardo27/aloe_webdriver
def should_include_link_text(self, link_text, link_url):
    """
    Assert a link containing the provided text points to the provided URL.
    """
    return world.browser.find_element_by_xpath(str(
        '//a[@href="%s"][contains(., %s)]' %
        (link_url, string_literal(link_text))))
コード例 #2
0
ファイル: __init__.py プロジェクト: jricardo27/aloe_webdriver
def no_see_tooltip(self, tooltip):
    """
    Assert an element with the given tooltip (title) is not visible.
    """
    elem = world.browser.find_elements_by_xpath(str(
        '//*[@title=%(tooltip)s or @data-original-title=%(tooltip)s]' %
        dict(tooltip=string_literal(tooltip))))
    elem = [e for e in elem if e.is_displayed()]
    assert_false(elem)
コード例 #3
0
ファイル: __init__.py プロジェクト: jricardo27/aloe_webdriver
def click_on_label(self, label):
    """
    Click on the given label.

    On a correctly set up form this will highlight the appropriate field.
    """

    elem = world.browser.find_element_by_xpath(str(
        '//label[normalize-space(text())=%s]' % string_literal(label)))
    elem.click()
コード例 #4
0
ファイル: __init__.py プロジェクト: nimbis/aloe_webdriver
def should_include_link_text(self, link_text, link_url):
    """
    Assert a link containing the provided text points to the provided URL.
    """

    assert_true(ElementSelector(
        world.browser,
        str('//a[@href="%s"][contains(., %s)]' %
            (link_url, string_literal(link_text))),
        filter_displayed=True,
    ))
コード例 #5
0
def should_include_link_text(self, link_text, link_url):
    """
    Assert a link containing the provided text points to the provided URL.
    """

    elements = ElementSelector(
        world.browser,
        str('//a[@href="%s"][contains(., %s)]' %
            (link_url, string_literal(link_text))),
        filter_displayed=True,
    )
    if not elements:
        raise AssertionError("Expected link not found.")
コード例 #6
0
def should_include_link_text(self, link_text, link_url):
    """
    Assert a link containing the provided text points to the provided URL.
    """

    elements = ElementSelector(
        world.browser,
        str('//a[@href="%s"][contains(., %s)]' %
            (link_url, string_literal(link_text))),
        filter_displayed=True,
    )
    if not elements:
        raise AssertionError("Expected link not found.")
コード例 #7
0
ファイル: __init__.py プロジェクト: nimbis/aloe_webdriver
def click_on_label(self, label):
    """
    Click on the given label.

    On a correctly set up form this will highlight the appropriate field.
    """

    elem = ElementSelector(
        world.browser,
        str('//label[normalize-space(text())=%s]' % string_literal(label)),
        filter_displayed=True,
    )
    assert_true(elem, "Cannot find a label with text '{}'.".format(label))
    elem.click()
コード例 #8
0
ファイル: __init__.py プロジェクト: nimbis/aloe_webdriver
def find_by_tooltip(browser, tooltip):
    """
    Find elements with the given tooltip.

    :param browser: ``world.browser``
    :param tooltip: Tooltip to search for

    Returns: an :class:`ElementSelector`
    """

    return ElementSelector(
        world.browser,
        str('//*[@title=%(tooltip)s or @data-original-title=%(tooltip)s]' %
            dict(tooltip=string_literal(tooltip))),
        filter_displayed=True,
    )
コード例 #9
0
def find_by_tooltip(browser, tooltip):
    """
    Find elements with the given tooltip.

    :param browser: ``world.browser``
    :param tooltip: Tooltip to search for

    Returns: an :class:`ElementSelector`
    """

    return ElementSelector(
        world.browser,
        str('//*[@title=%(tooltip)s or @data-original-title=%(tooltip)s]' %
            dict(tooltip=string_literal(tooltip))),
        filter_displayed=True,
    )
コード例 #10
0
def click_on_label(self, label):
    """
    Click on the given label.

    On a correctly set up form this will highlight the appropriate field.
    """

    elem = ElementSelector(
        world.browser,
        str('//label[normalize-space(text())=%s]' % string_literal(label)),
        filter_displayed=True,
    )
    if not elem:
        raise AssertionError(
            "Cannot find a label with text '{}'.".format(label))
    elem.click()
コード例 #11
0
ファイル: __init__.py プロジェクト: nimbis/aloe_webdriver
def contains_content(browser, content):
    """
    Search for an element that contains the whole of the text we're looking
    for in it or its subelements, but whose children do NOT contain that
    text - otherwise matches <body> or <html> or other similarly useless
    things.
    """
    for elem in browser.find_elements_by_xpath(str(
            '//*[contains(normalize-space(.), {content}) '
            'and not(./*[contains(normalize-space(.), {content})])]'
            .format(content=string_literal(content)))):

        try:
            if elem.is_displayed():
                return True
        except StaleElementReferenceException:
            pass

    return False
コード例 #12
0
def contains_content(browser, content):
    """
    Search for an element that contains the whole of the text we're looking
    for in it or its subelements, but whose children do NOT contain that
    text - otherwise matches <body> or <html> or other similarly useless
    things.
    """
    for elem in browser.find_elements_by_xpath(
            str('//*[contains(normalize-space(.), {content}) '
                'and not(./*[contains(normalize-space(.), {content})])]'.
                format(content=string_literal(content)))):

        try:
            if elem.is_displayed():
                return True
        except StaleElementReferenceException:
            pass

    return False