Skip to content

Decorators for test methods

horejsek edited this page Mar 5, 2013 · 1 revision

ShouldBeOnPage

class TestCase(WebdriverTestCase):
    @GoToPage('http://www.google.com')
    @ShouldBeOnPage('doodles/finder/2013/All%20doodles')
    def test(self):
        self.click('gbqfsb')
        self.contains_text('Doodles')

ShouldBeError

By default WebdriverTestCase looks for error messages in elements with class error. If you want to test that some page have some error message, use this decorator.

You can override method get_errors which returns list of error messages on page.

class TestCase(WebdriverTestCase):
    @ShouldBeError('some-error')
    def test(self):
        # ...

CanBeError

Same as ShouldBeError, but no error is also OK.

Clone this wiki locally