def test_filter_tasks(): config.browser_name = 'chrome' 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) s('#new-todo').set_value('a').press_enter() s('#new-todo').set_value('b').press_enter() s('#new-todo').set_value('c').press_enter() ss('#todo-list li').should(have.exact_texts('a', 'b', 'c')) ss('#todo-list li').element_by( have.exact_text('b')).element('.toggle').click() s(by.link_text('Active')).click() ss('#todo-list li').filtered_by(be.visible).should( have.exact_texts('a', 'c')) s(by.link_text('Completed')).click() ss('#todo-list li').filtered_by(be.visible).should(have.exact_texts('b')) s(by.link_text('All')).click() ss('#todo-list li').filtered_by(be.visible).should( have.exact_texts('a', 'b', 'c'))
def test_complete_todo(): browser.open('http://todomvc.com/examples/emberjs/') s('#new-todo').type('a').press_enter() s('#new-todo').type('b').press_enter() s('#new-todo').type('c').press_enter() ss('#todo-list>li').should(have.exact_texts('a', 'b', 'c')) s('#todo-list>li:nth-of-type(2) .toggle').click() ss('#todo-list>li.completed').should(have.exact_texts('b')) ss('#todo-list>li:not(.completed)').should(have.exact_texts('a', 'c'))
def test_adding_and_completing_tasks(): s('#new-todo').type('a').press_enter() s('#new-todo').type('b').press_enter() s('#new-todo').type('c').press_enter() ss('#todo-list>li').should(have.exact_texts('a', 'b', 'c')) s('#todo-list>li:nth-child(2) .toggle').click() s('#todo-list>li:nth-child(2)').should(have.css_class('completed')) s('#todo-list>li:nth-child(1)').should(have.no.css_class('completed')) s('#todo-list>li:nth-child(3)').should(have.no.css_class('completed'))
def test_filter_tasks(): visit('https://todomvc4tasj.herokuapp.com') s('#new-todo').set_value('a').press_enter() s('#new-todo').set_value('b').press_enter() s('#new-todo').set_value('c').press_enter() ss('#todo-list li').should(have.exact_texts('a', 'b', 'c')) ss('#todo-list li').element_by( have.exact_text('b')).element('.toggle').click() s(by.link_text('Active')).click() ss('#todo-list li').filtered_by(be.visible).should( have.exact_texts('a', 'c')) s(by.link_text('Completed')).click() ss('#todo-list li').filtered_by(be.visible).should(have.exact_texts('b')) s(by.link_text('All')).click() ss('#todo-list li').filtered_by(be.visible).should( have.exact_texts('a', 'b', 'c'))
def assert_tasks(*task_texts): tasks.should(have.exact_texts(*task_texts))
def test_condition_have_exact_texts(): assert have.exact_texts("a", "b", "c").expected == ("a", "b", "c")
def test_search_inner_selene_collection(): given_active("a", "b") s("#todo-list").all("li").should(have.exact_texts("a", "b"))
def assert_completed_todos(self, *names: str): self.todos.filtered_by(self.be_completed).should(have.exact_texts(*names)) return self
def assert_all_todos(self, *names: str): self.todos.should(have.exact_texts(*names)) return self
def should_be(*texts): _elements.filtered_by(be.visible).should(have.exact_texts(*texts))
def test_should_fails(): given_active("a", "b") with pytest.raises(TimeoutException): ss("#todo-list>li").should(have.exact_texts("a.", "b."), timeout=0.1)
def test_should_passes(): given_active("a", "b") ss("#todo-list>li").should(have.exact_texts("a", "b"))
def test_remove_one_job(): MainPage().remove_job('test') MainPage().jobs_list.should(have.exact_texts('giant', 'chine', 'destro')) time.sleep(1)
def test_user_add_jos(): MainPage().add_job('destro').add_job('test').add_job('chine').add_job('giant').jobs_list.should(have.size(4)) MainPage().jobs_list.should(have.exact_texts('giant', 'chine', 'test', 'destro'))
def assert_active_todos(self, *names: str): self.todos.filtered_by(self.be_active).should(have.exact_texts(*names)) return self
def should_be(self, *texts): self._elements.should(have.exact_texts(*texts))
def should_have_list(self, *names): self._todos.should(have.exact_texts(*names)) return self