示例#1
0
def test_complex_locator_based_on_by_locators():
    GIVEN_PAGE\
        .opened_with_body(
            '''
            <div id="container">
                <div>
                    <div>
                        <label>First</label>
                    </div>
                    <div>
                        <a href="#first">go to Heading 1</a>
                    </div>
                </div>
                <div>
                    <div>
                        <label>Second</label>
                    </div>
                    <div>
                        <a href="#second">go to Heading 2</a>
                    </div>
                </div>
            </div>
            <h1 id="first">Heading 1</h2>
            <h2 id="second">Heading 2</h2>
            ''')

    driver.element('#container')\
        .element(by.text('Second'))\
        .element(by.be_parent())\
        .element(by.be_following_sibling())\
        .element(by.be_first_child())\
        .click()
    assert ('second' in driver.current_url) is True
示例#2
0
 def parent_element(self):
     return self.element(by.be_parent())