Ejemplo n.º 1
0
def test_filter_tasks():
    browser.open('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.element('#new-todo').set_value('a').press_enter()
    browser.element('#new-todo').set_value('b').press_enter()
    browser.element('#new-todo').set_value('c').press_enter()
    browser.all('#todo-list li').should(have.exact_texts('a', 'b', 'c'))

    browser.all('#todo-list li').element_by(
        have.exact_text('b')).element('.toggle').click()
    browser.element(by.link_text('Active')).click()
    browser.all('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'c'))

    browser.element(by.link_text('Completed')).click()
    browser.all('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('b'))

    browser.element(by.link_text('All')).click()
    browser.all('#todo-list li').filtered_by(be.visible).should(
        have.exact_texts('a', 'b', 'c'))
Ejemplo n.º 2
0
    def test_filter_tasks(self):
        browser.open('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))
        browser.wait_to(have.title(u'TroopJS • TodoMVC'))

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

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

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

        browser.element(by.link_text("Active")).click()
        browser.all("#todo-list>li").filtered_by(be.visible).should(
            have.texts('a', 'c'))

        browser.element(by.link_text("Completed")).click()
        browser.all("#todo-list>li").filtered_by(be.visible).should(
            have.texts('b'))
    def test_selene_demo(self):
        tasks = browser.all("#todo-list>li")
        active_tasks = tasks.filtered_by(have.css_class("active"))

        browser.open(app_url)
        browser.should(have.js_returned(True, is_TodoMVC_loaded))

        for task_text in ["1", "2", "3"]:
            browser.element("#new-todo").set_value(task_text).press_enter()
        tasks.should(have.texts("1", "2",
                                "3")).should_each(have.css_class("active"))
        browser.element("#todo-count").should(have.text('3'))

        tasks[2].element(".toggle").click()
        active_tasks.should(have.texts("1", "2"))
        active_tasks.should(have.size(2))

        tasks.filtered_by(have.css_class("completed")).should(have.texts("3"))
        tasks.element_by(not_(have.css_class("completed"))).should(
            have.text("1"))
        tasks.filtered_by(not_(have.css_class("completed"))).should(
            have.texts("1", "2"))

        browser.element(by.link_text("Active")).click()
        tasks[:2].should(have.texts("1", "2"))
        tasks[2].should(be.hidden)

        browser.element(by.id("toggle-all")).click()
        browser.element("//*[@id='clear-completed']").click()
        tasks.should(be.empty)
Ejemplo n.º 4
0
def get_locator_strategy(locator):
    if "css=" in locator:
        return locator.replace("css=", "")
    elif "id=" in locator:
        return locator.replace("id=", "#")
    elif "linkText=" in locator:
        return by.link_text(locator.replace("linkText=", ""))
    elif "xpath=" in locator:
        return by.xpath(locator.replace("xpath=", ""))
    else:
        raise NotImplementedError(f"Wrong locator format {locator}")
Ejemplo n.º 5
0
    def test_filter_tasks(self):
        browser.open(APP_URL)
        clear_completed_js_loaded = "return $._data($('#clear-completed').get(0), 'events').hasOwnProperty('click')"
        browser.wait.for_(have.js_returned(True, clear_completed_js_loaded))

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

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

        browser.all("#todo-list>li").element_by(
            have.exact_text('b')).element(".toggle").click()

        browser.element(by.link_text("Active")).click()
        browser.all("#todo-list>li").filtered_by(be.visible).should(
            have.texts('a', 'c'))

        browser.element(by.link_text("Completed")).click()
        browser.all("#todo-list>li").filtered_by(be.visible).should(
            have.texts('b'))
Ejemplo n.º 6
0
def test_by_link_text():
    assert by.link_text("text") == ('link text', 'text')
Ejemplo n.º 7
0
def filter_completed():
    browser.element(by.link_text("Completed")).click()
Ejemplo n.º 8
0
def filter_active():
    browser.element(by.link_text("Active")).click()