當前位置: 首頁>>代碼示例>>Python>>正文


Python dominic.DOM類代碼示例

本文整理匯總了Python中dominic.DOM的典型用法代碼示例。如果您正苦於以下問題:Python DOM類的具體用法?Python DOM怎麽用?Python DOM使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DOM類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: select_by_attribute_id

def select_by_attribute_id(context):
    "selecting by attribute (id)"
    dom = DOM(context.html)

    (body, ) = dom.find("[id=firstp]")
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
開發者ID:eroh92,項目名稱:dominic,代碼行數:7,代碼來源:test_selectors.py

示例2: select_html

def select_html(context):
    "selecting html"
    dom = DOM(context.html)

    html = dom.get("html")
    assert that(html).is_a(Element)
    assert that(html.attribute['id']).equals("html")
開發者ID:eroh92,項目名稱:dominic,代碼行數:7,代碼來源:test_selectors.py

示例3: select_by_id

def select_by_id(context):
    "selecting by id"
    dom = DOM(context.html)

    body = dom.find("#firstp").first()
    assert that(body).is_a(Element)
    assert that(body.attribute['id']).equals("firstp")
開發者ID:eroh92,項目名稱:dominic,代碼行數:7,代碼來源:test_selectors.py

示例4: text_return_the_text_within_element

def text_return_the_text_within_element(context):
    "Element().text() returns the text content"
    dom = DOM(context.html)

    p = dom.find("#the-only-paragraph").first()

    assert that(p.text()).equals("the only one in th whole damn thing!?")
開發者ID:eroh92,項目名稱:dominic,代碼行數:7,代碼來源:test_manipulation.py

示例5: attr_retrieves_each_attribute_by_name

def attr_retrieves_each_attribute_by_name(context):
    "attr retrieves attributes each attribute by name"
    dom = DOM(context.html)

    ul = dom.find("#objects").first()

    assert that(ul.attr('id')).equals('objects')
    assert that(ul.attr('class')).equals('list no-bullets')
開發者ID:gabrielfalcao,項目名稱:dominic,代碼行數:8,代碼來源:test_manipulation.py

示例6: select_by_class_with_many_classes

def select_by_class_with_many_classes(context):
    "selecting by many classes at once"
    dom = DOM(context.html)

    elements = dom.find("li.stuff.thing")
    assert that(elements).the_attribute('tag').equals('li')

    assert that(elements[0].attribute['id']).equals('house')
開發者ID:eroh92,項目名稱:dominic,代碼行數:8,代碼來源:test_selectors.py

示例7: select_paragraphs

def select_paragraphs(context):
    "selecting paragraphs"
    dom = DOM(context.html)

    paragraphs = dom.find("p")

    assert that(paragraphs).is_a(ElementSet)
    assert paragraphs.length is 6
開發者ID:eroh92,項目名稱:dominic,代碼行數:8,代碼來源:test_attributes.py

示例8: select_by_child

def select_by_child(context):
    "selecting by parent > child, mixing many kinds of selectors"
    dom = DOM(context.html)

    elements = dom.find(
        "ul#objects > li.geometry"
    )
    assert that(elements).in_each('tag').matches(['li', 'li'])
    assert that(elements).in_each("attribute['id']").matches(['ball', 'square'])
開發者ID:eroh92,項目名稱:dominic,代碼行數:9,代碼來源:test_selectors.py

示例9: select_by_child_complex

def select_by_child_complex(context):
    "selecting by parent > child, mixing many kinds of selectors"
    dom = DOM(context.html)

    elements = dom.find(
        "div.ball.dog.square.house.puppet#like-this-one > ul#objects > li.geometry"
    )
    assert that(elements).in_each('tag').matches(['li', 'li'])
    assert that(elements).in_each("attribute['id']").matches(['ball', 'square'])
開發者ID:eroh92,項目名稱:dominic,代碼行數:9,代碼來源:test_selectors.py

示例10: select_paragraphs

def select_paragraphs(context):
    "selecting paragraphs"
    dom = DOM(context.html)

    identifiers = ["firstp", "ap", "sndp", "en", "sap", "first"]
    paragraphs = dom.find("p")

    assert that(dom).is_a(DOM)
    assert that(paragraphs).in_each("attribute['id']").matches(identifiers)
開發者ID:eroh92,項目名稱:dominic,代碼行數:9,代碼來源:test_selectors.py

示例11: select_by_class

def select_by_class(context):
    "selecting by class name"
    dom = DOM(context.html)

    div = dom.find(".nothiddendiv").first()
    assert that(div).is_a(Element)
    assert that(div.attribute['id']).equals("nothiddendiv")
    assert that(div.attribute['style']).has("height:1px;")
    assert that(div.attribute['style']).has("background:white;")
開發者ID:eroh92,項目名稱:dominic,代碼行數:9,代碼來源:test_selectors.py

示例12: html_return_the_html_string

def html_return_the_html_string(context):
    "Element().html() returns the html string"
    dom = DOM(context.html)

    p = dom.find("#the-only-paragraph").first()

    assert that(p.html()).equals(
        '<p id="the-only-paragraph">the only one in th whole damn thing!?</p>'
    )
開發者ID:eroh92,項目名稱:dominic,代碼行數:9,代碼來源:test_manipulation.py

示例13: select_by_attribute_ends_with_with_quotes

def select_by_attribute_ends_with_with_quotes(context):
    "selecting attribute that ends with certain value with quotes"
    dom = DOM(context.html)

    elements = dom.find("ul#packages > li[id$=\"nd\"]")
    assert that(elements).in_each("attribute['id']").matches(
        [
            'java island',
        ]
    )
開發者ID:gabrielfalcao,項目名稱:dominic,代碼行數:10,代碼來源:test_selectors.py

示例14: first_returns_the_first

def first_returns_the_first(context):
    "selecting all childs of some element"
    dom = DOM(context.html)

    elements = dom.find("#objects li")

    p = elements.first()
    assert that(p).is_a(Element)
    assert that(p.tag).equals("li")
    assert that(p.attribute['id']).equals("ball")
    assert that(p.text()).equals("to kick")
開發者ID:eroh92,項目名稱:dominic,代碼行數:11,代碼來源:test_manipulation.py

示例15: last_returns_the_last

def last_returns_the_last(context):
    "selecting all childs of some element"
    dom = DOM(context.html)

    elements = dom.find("#objects li")

    p = elements.last()
    assert that(p).is_a(Element)
    assert that(p.tag).equals("li")
    assert that(p.attribute['id']).equals("puppet")
    assert that(p.text()).equals("to care with")
開發者ID:eroh92,項目名稱:dominic,代碼行數:11,代碼來源:test_manipulation.py


注:本文中的dominic.DOM類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。