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)
def test_by_id(): assert by.id('c') == ('id', 'c')
def login_succeed(self): s(by.id('inventory_container')).should(be.existing)
def login(self, username, password): self.open().should_be_opened() s(by.id('user-name')).should(be.blank).type(username) s(by.id('password')).should(be.blank).type(password) s(by.id('login-button')).should(be.clickable).click() return self
def should_be_opened(self): s(by.id('login_button_container')).should(be.visible) return self
def should_be_opened(self): s(by.id('inventory_container')).should(be.visible) return self
def should_be_opened(self): s(by.id('cart_contents_container')).should(be.visible) return self