def test_click(): page = TestAgent(TestApp()).get('/page1') assert_equal( page.one("//a[1]").click().request.path, '/page1' ) assert_equal( page.one("//a[2]").click().request.path, '/page2' ) assert_equal( len(page.all("//a")), 3 ) assert_raises( testino.MultipleMatchesError, page.one, "//a" ) assert_equal( page.click('//a[1]').request.path, page.one('//a[1]').click().request.path ) assert_equal( page.click(text=u'page 1').request.path, page.one('//a[text()="page 1"]').click().request.path ) assert_equal( page.click(href=u'page1').request.path, page.one('//a[@href="page1"]').click().request.path ) assert_equal( page.click(text=u'page 1', href=u'page1').request.path, page.one('//a[text()="page 1" and @href="page1"]').click().request.path )
def test_click_many(): body = """<p><a href="page1">page 1</a><a href="page1">page 1</a></p>""" agent = TestAgent(wz.Response(body)).get('/') assert_raises( testino.MultipleMatchesError, agent.click, text="page 1" ) assert agent.click(text="page 1", many=True)