Esempio n. 1
0
def test_can_make_screenshot_automatically():
    visit(start_page)
    config.timeout = 0.1
    with pytest.raises(TimeoutException) as ex:
        s("#selene_link").should_have(exact_text("Selen site"))
    expected = os.path.join(get_default_screenshot_folder(),
                            'screen_{id}.png'.format(id=get_screen_id()))
    assert os.path.exists(expected)
Esempio n. 2
0
def test_waits_for_present_in_dom_and_visibility():
    GIVEN_PAGE.opened_with_body('''
            <h2 id="second">Heading 2</h2>''')
    WHEN.load_body_with_timeout(
        '''
            <a href="#second">go to Heading 2</a>
            <h2 id="second">Heading 2</h2>''', 500)

    driver.all('a').element_by(exact_text('go to Heading 2')).click()
    assert ("second" in driver.current_url) is True
Esempio n. 3
0
def test_search_is_postponed_until_actual_action_like_questioning_displayed():
    GIVEN_PAGE.opened_empty()
    element = driver.all('.will-appear').element_by(exact_text('Kate'))

    WHEN.load_body('''
                   <ul>Hello to:
                       <li class="will-appear">Bob</li>
                       <li class="will-appear">Kate</li>
                   </ul>''')
    assert element.is_displayed() is True
Esempio n. 4
0
def test_waits_for_visibility():
    GIVEN_PAGE\
        .opened_with_body(
            '''
            <a href="#second" style="display:none">go to Heading 2</a>
            <h2 id="second">Heading 2</h2>''')\
        .execute_script_with_timeout(
            'document.getElementsByTagName("a")[0].style = "display:block";',
            500)

    driver.all('a').element_by(exact_text('go to Heading 2')).click()
    assert ("second" in driver.current_url) is True
Esempio n. 5
0
def test_fails_on_timeout_during_waiting_for_visibility():
    config.timeout = 0.25
    GIVEN_PAGE\
        .opened_with_body(
            '''
            <a href='#second' style='display:none'>go to Heading 2</a>
            <h2 id='second'>Heading 2</h2>''')\
        .execute_script_with_timeout(
            'document.getElementsByTagName("a")[0].style = "display:block";',
            500)

    with pytest.raises(TimeoutException):
        driver.all('a').element_by(exact_text('go to Heading 2')).click()
    assert ("second" in driver.current_url) is False
Esempio n. 6
0
    def test_filter_tasks(self):
        browser.visit(APP_URL)

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
Esempio n. 7
0
    def test_filter_tasks(self):
        browser.open_url(APP_URL)
        clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
        browser.wait_to(have.js_returned_true(clear_completed_js_loaded))

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
Esempio n. 8
0
    def test_filter_tasks(self):
        browser.open_url('https://todomvc4tasj.herokuapp.com/')
        clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
        browser.wait_to(have.js_returned_true(clear_completed_js_loaded), timeout=config.timeout*3)
        browser.wait_to(have.title(u'TroopJS • TodoMVC'))

        s('#new-todo').should(be.enabled).set_value('a').press_enter()
        s('#new-todo').should(be.enabled).set_value('b').press_enter()
        s('#new-todo').should(be.enabled).set_value('c').press_enter()

        ss("#todo-list>li").should(have.texts('a', 'b', 'c'))

        ss("#todo-list>li").element_by(exact_text('b')).find(".toggle").click()

        s(by_link_text("Active")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('a', 'c'))

        s(by_link_text("Completed")).click()
        ss("#todo-list>li").filtered_by(be.visible).should(have.texts('b'))
Esempio n. 9
0
def toggle(task_name):
    tasks.element_by(exact_text(task_name)).element(".toggle").click()
Esempio n. 10
0
 def should_have_items_left(self, number_of_active_tasks):
     self.container.find("#todo-count>strong").should_have(
         exact_text(str(number_of_active_tasks)))
Esempio n. 11
0
 def _task_element(self, text):
     return self._elements().findBy(exact_text(text))
Esempio n. 12
0
def toggle(task_text):
    tasks.findBy(exact_text(task_text)).find(".toggle").click()
Esempio n. 13
0
def test_can_init_custom_browser_on_visit():
    selene.config.browser_name = Browser.CHROME
    visit(start_page)
    s("#selene_link").should_have(exact_text("Selene site"))
Esempio n. 14
0
def test_ru_text():
    s("#ru-text").should_have(exact_text(u"Селен"))
Esempio n. 15
0
def test_auto_start():
    open_url(start_page)
    s("#header").should_have(exact_text("Selene"))
Esempio n. 16
0
def test_manual_start_2():
    visit(start_page)
    s("#selene_link").should_have(exact_text("Selene site"))
Esempio n. 17
0
def toggle(task_text):
    tasks.findBy(exact_text(task_text)).find(".toggle").click()
Esempio n. 18
0
def toggle(task_text):
    _elements.element_by(exact_text(task_text)).find(".toggle").click()
Esempio n. 19
0
def test_can_init_default_browser_on_visit():
    open_url(start_page)
    s("#header").should_have(exact_text("Selene"))
Esempio n. 20
0
def test_search_is_lazy_and_does_not_start_on_creation_for_both_collection_and_indexed(
):
    GIVEN_PAGE.opened_empty()
    non_existent_element = driver.all('.non-existing').element_by(
        exact_text('Kate'))
    assert str(non_existent_element)
Esempio n. 21
0
def delete(task_name):
    tasks.element_by(exact_text(task_name)).hover().element(".destroy").click()
Esempio n. 22
0
def test_auto_start_2():
    open_url(start_page)
    s("#selene_link").should_have(exact_text("Selene site"))
Esempio n. 23
0
def edit(old_task_name, new_task_name):
    tasks.element_by(exact_text(old_task_name)).double_click()
    tasks.element_by(css_class("editing")).element(".edit").set_value(
        new_task_name).press_enter()
Esempio n. 24
0
def test_can_init_custom_browser_on_visit():
    selene.config.browser_name = BrowserName.MARIONETTE
    open_url(start_page)
    s("#selene_link").should_have(exact_text("Selene site"))
Esempio n. 25
0
def exact_text(value):
    return conditions.exact_text(value)
Esempio n. 26
0
def test_manual_start():
    driver = get_test_driver()
    set_driver(driver)
    open_url(start_page)
    s("#header").should_have(exact_text("Selene"))