new_contents: #!/usr/bin/python2.4
  #
  # Copyright (c) 2005-2006 rPath, Inc.
  #
  # All Rights Reserved
  #
  
  #
  # A basic selenium wrapper and some test cases. Requires:
  #
  # selenium-remote-control=selenium.rpath.org@rpl:devel
  # selenium-remote-control-python=selenium.rpath.org@rpl:devel
  # selenium-core=contrib.rpath.org@rpl:devel
  #
  # Start the selenium-server before running this test suite:
  #
  #  /usr/sbin/selenium-server
  #
  
  import testsuite
  testsuite.setup()
  
  import sys
  import os
  import socket
  import selenium
  
  import mint_rephelp
  from mint_rephelp import MINT_HOST, MINT_PROJECT_DOMAIN, MINT_DOMAIN
  
  from mint import buildtypes
  
  class SeleniumHelper(mint_rephelp.BaseWebHelper):
      def setUp(self):
          mint_rephelp.BaseWebHelper.setUp(self)
  
          try:
              seleniumHost = os.environ.get("SELENIUM_HOST", "localhost")
              seleniumPort = os.environ.get("SELENIUM_PORT", "4444")
              seleniumBrowser = os.environ.get("SELENIUM_BROWSER", "*firefox")
  
              self.s = selenium.selenium(seleniumHost, seleniumPort, seleniumBrowser, self.URL)
              self.s.start()
          except socket.error:
              raise RuntimeError("Please make sure a selenium-server is running on %s:%s." % (seleniumHost, seleniumPort))
  
      def tearDown(self):
          self.s.stop()
          mint_rephelp.BaseWebHelper.tearDown(self)
  
      def clickAndWait(self, click, timeout = 10000):
          self.s.click(click)
          self.s.wait_for_page_to_load(timeout)
  
  
  class WebPageTest(SeleniumHelper):
      def createTestGroup(self, client, hostname = 'test', domainname = MINT_PROJECT_DOMAIN):
          self.setupProject(client, hostname, domainname)
  
          self.addComponent('testcase:source', '1.0.0', 'is: x86')
          self.addComponent('testcase:runtime', '1.0.0', 'is: x86')
          self.addCollection('testcase', '1.0.0', ['testcase:runtime'], defaultFlavor = 'is: x86')
          self.addComponent('group-test:source', '1.0.0')
          trv = self.addCollection('group-test', '1.0.0', ['testcase'], defaultFlavor = 'is: x86')
  
      def clickAjax(self, locator, accept, timeout = 10000):
          self.s.click(locator)
  
          for x in range(0, timeout / 100):
              if accept in self.s.get_body_text():
                  return
              sleep(0.1)
  
          raise RuntimeError("Script-driven text never appeared: %s" % accept)
  
      def testCreateProject(self):
          client, userId = self.quickMintUser("foouser", "foopass")
  
          self.setOptIns("foouser")
  
          self.s.open(self.URL)
          self.s.type("username", "foouser")
          self.s.type("password", "foopass")
          self.clickAndWait("signInSubmit")
  
          self.failUnless("Edit my account" in self.s.get_body_text())
  
          self.clickAndWait("link=create a new project")
          self.s.type("hostname", "test")
          self.s.type("title", "Test Project")
  
          self.clickAndWait("newProject")
          self.failUnless("This is a fledgling project" in self.s.get_body_text())
  
      def testGroupBuilder(self):
          client, userId = self.quickMintUser("foouser", "foopass")
          self.newProject(client, hostname = 'test')
  
          self.setOptIns("foouser")
  
          self.s.open(self.URL)
          self.s.type("username", "foouser")
          self.s.type("password", "foopass")
          self.clickAndWait("signInSubmit")
  
          self.failUnless("Edit my account" in self.s.get_body_text())
  
          self.createTestGroup(client)
  
          self.clickAndWait("link=Test Project")
          self.clickAndWait("link=Manage Builds")
          self.clickAndWait("link=Create a new build")
  
          # Create Build button should be disabled
          self.failUnless(not self.s.is_editable("submitButton"))
  
          # pick the available group
          self.clickAjax("link=group-test", "test.rpath.local@rpl:devel")
          self.clickAjax("link=test.rpath.local@rpl:devel", "1.0.0-1-1")
          self.clickAjax("link=1.0.0-1-1", "is: x86")
          self.clickAjax("flavorId0", "group-test=1.0.0-1-1 [is: x86]")
  
          # Create Build button should be enabled now
          self.failUnless(self.s.is_editable("submitButton"))
  
          # select stub image
          self.s.click("buildtype_%d_label" % buildtypes.STUB_IMAGE)
          self.clickAndWait("submitButton")
  
          self.failUnless("Build: Test Project" in self.s.get_body_text())
  
  
  if __name__ == "__main__":
      testsuite.main()
  
subject: add a basic selenium harness and some tests