Source

digrsser / tests / webtests / pages.py

Full commit
__author__ = 'juha'

from webtests.objects import WebBrowser, PageObject, PageElement, PageElements, TextInput, Checkbox

class WelcomePage(PageObject):

  def __init__(self, browser):
    self.login = PageElement('a.login')

class TestLoginPage(PageObject):

  def __init__(self, browser):
    self.email = TextInput('input#email')
    self.check_as_admin = Checkbox('input#admin')
    self.submit = PageElement('input#submit-login')

    if not browser.find_by_css('#email'):
      browser.visit("/_ah/login")

class InstallPage(PageObject):

  def __init__(self, browser):
    self.install = PageElement('input#install')

class SubElements(object):
  def __new__(cls, selector, elementcls):
    browser = WebBrowser()
    elements = browser.find_by_css(selector)

    return elements

  def __init__(self, selector, elementscls):
    pass


class SubscriptionElement(PageElement):
  def __init__(self, browser):
    self.title_link = PageElement('div.subscription a')

class SubListPage(PageObject):

  def __init__(self, browser):
    self.url = PageElement('input#url')
    self.grouping_rules = PageElements('ul#grouping_rule input')
    self.save = PageElement('input#submit')
    self.cancel = PageElement('input#cancel')

    self.subscriptions = SubElements('div.subscriptions subscription', SubscriptionElement)

class SubEdit(PageObject):

  def __init__(self, browser):
    self.url = PageElement('input#url')
    self.grouping_rules = PageElements('ul#grouping_rule input')
    self.save = PageElement('input#submit')
    self.cancel = PageElement('input#cancel')