コード例 #1
0
class BaseTestCase(TestCase):

    s = WebdriverFactory.createDriver()  #driver
    p = TestConfig()

    @classmethod
    def setUpClass(cls):
        "open the testUrl"
        testUrl = cls.p.get('url')
        user = cls.p.get('user')
        pwd = cls.p.get('pwd')

        cls.s.open(testUrl)

    @classmethod
    def tearDownClass(cls):
        cls.s.quit()

    def setUp(self):
        log.info(">>>>>>start " + self._testMethodName + " <<<<<<")

    def tearDown(self):
        if sys.exc_info()[0]:
            log.error(sys.exc_info()[1])
            self.s.screenshot(self._testMethodName + '.png')
        log.info(">>>>>>end " + self._testMethodName + " <<<<<<")
コード例 #2
0
ファイル: mainWindow.py プロジェクト: flavour/helios
 def runTestSuite(self):
     # call static method of the base class for all Sahana test case classes
     # this method will ensure that one Selenium instance exists and can be shared
     SahanaTest.setUpHierarchy(self.radioB.get(), self.browserPath.get(),
                               self.ipAddr.get(), self.ipPort.get(),
                               self.URL.get() + self.app.get())
     #        SahanaTest.useSahanaAccount(self.adminUser.get(),
     #                                    self.adminPassword.get(),
     #                                   )
     self.clean = False
     testConfig = TestConfig()
     testModuleList = self.getTestCasesToRun()
     testConfig.test_main(testModuleList, self.radioB.get())
     call(["firefox", os.path.join("..", "results", testConfig.fileName)])
     if (not self.keepOpen):
         SahanaTest.selenium.stop(
         )  # This will close the Selenium/Browser window
     self.clean = True
コード例 #3
0
ファイル: mainWindow.py プロジェクト: sinsai/Sahana_eden
 def runTestSuite(self):
     # call static method of the base class for all Sahana test case classes
     # this method will ensure that one Selenium instance exists and can be shared
     SahanaTest.setUpHierarchy(self.radioB.get(),
                               self.browserPath.get(),
                               self.ipAddr.get(),
                               self.ipPort.get(),
                               self.URL.get() + self.app.get()
                              )
     SahanaTest.useSahanaAccount(self.adminUser.get(),
                                 self.adminPassword.get(),
                                )
     self.clean = False
     testConfig = TestConfig()
     testModuleList = self.getTestCasesToRun()
     testConfig.test_main(testModuleList, self.radioB.get())
     call(["firefox", os.path.join("..", "results", testConfig.fileName)])
     if (not self.keepOpen):
        SahanaTest.selenium.stop() # This will close the Selenium/Browser window 
     self.clean = True
コード例 #4
0
ファイル: mainWindow.py プロジェクト: flavour/helios
    def testModulepanel(self, panel):
        self.moduleList = TestConfig().getTestModuleDetails()
        Label(panel, text="Test Modules").pack(side=TOP)
        Label(panel,
              text="Select the test modules that you would like to run.").pack(
                  side=TOP, anchor=W)
        detailPanel = Frame(panel)
        detailPanel.pack(side=TOP, anchor=W, fill=X)
        self.checkboxModules = []
        self.buttonList = []
        self.moduleName = []
        self.labelList = []
        i = 0
        details = {}
        for details in self.moduleList:
            name = details["name"]
            self.moduleName.append(name)
            var = IntVar()

            chk = Checkbutton(detailPanel,
                              text=name,
                              variable=var,
                              command=self.toggleButton)
            self.checkboxModules.append(var)
            btnFrame = Frame(detailPanel)
            chk.grid(row=i // 2, column=i % 2 * 3, sticky=NW)
            lbl = Label(detailPanel,
                        text=self.testcaseTotals(self.moduleList[i]))
            lbl["fg"] = self.testcaseColour
            lbl.grid(row=i // 2, column=i % 2 * 3 + 1, sticky=NW)
            self.labelList.append(lbl)
            btn = Button(btnFrame, text="Select tests")
            btn.grid()
            btnFrame.grid(row=i // 2, column=i % 2 * 3 + 2, sticky=NW)
            btnFrame.grid_remove()
            self.buttonList.append(btnFrame)

            def handler(event, i=i, module=name, details=details):
                return self.selectTests(i, module, details)

            btn.bind(sequence="<ButtonRelease-1>", func=handler)
            i += 1
コード例 #5
0
ファイル: regressionTests.py プロジェクト: sinsai/Sahana_eden
        # The 1st argument is taken to be the config file:
        config_filename = args[1]
        exec("from %s import Settings" % config_filename)
        testSettings = Settings()
        browser = testSettings.radioB
        SahanaTest.setUpHierarchy(browser,
                                  testSettings.browserPath,
                                  testSettings.ipAddr,
                                  testSettings.ipPort,
                                  testSettings.URL + testSettings.app
                                 )
        # When running non-interactively, Username/Password are blank
        SahanaTest.useSahanaAccount("",
                                    "",
                                   )
        testConfig = TestConfig()
        moduleList = testConfig.getTestModuleDetails()
        testList = testConfig.getTestCasesToRun(moduleList)
        suite = testConfig.suite
        for testModule in testList: # dotted notation module.class
            testConfig.overrideClassSortList(testModule["class"],
                                             testModule["tests"])
        # Invoke TestRunner
        buf = StringIO.StringIO()
        try:
            report_format = args[2]
        except:
            report_format = "html"

        if report_format == "xml": # Arg 2 is used to generate xml output for jenkins
            runner = XMLTestRunner(file("../results/regressionTest-%s.xml" % (browser.replace("*", "")),
コード例 #6
0
        os.chdir(path)
        sys.path = [path] + [os.path.join(path, "config")
                             ] + [p for p in sys.path]
        exec("from %s import Settings" % config_filename)

        testSettings = Settings()
        browser = testSettings.radioB
        SahanaTest.setUpHierarchy(browser, testSettings.browserPath,
                                  testSettings.ipAddr, testSettings.ipPort,
                                  testSettings.URL + testSettings.app)
        # When running non-interactively, Username/Password are blank
        SahanaTest.useSahanaAccount(
            "",
            "",
        )
        testConfig = TestConfig()
        moduleList = testConfig.getTestModuleDetails()
        testList = testConfig.getTestCasesToRun(moduleList)
        suite = testConfig.suite
        for testModule in testList:  # dotted notation module.class
            testConfig.overrideClassSortList(testModule["class"],
                                             testModule["tests"])
        # Invoke TestRunner
        buf = StringIO.StringIO()
        try:
            report_format = args[2]
        except:
            report_format = "html"

        if report_format == "xml":  # Arg 2 is used to generate xml output for jenkins
            runner = XMLTestRunner(
コード例 #7
0
ファイル: factory.py プロジェクト: andluo90/selenium-test
#-*- coding:UTF-8 -*-
__author__ = 'andluo'
from selenium import webdriver
from testConfig import TestConfig
from selenium2 import Selenium2

p = TestConfig()


class DeviceFactory:
    '设备工厂'

    @classmethod
    def creatAndroidDev(cls):
        nexus4 = {
            "deviceMetrics": {
                "width": 384,
                "height": 640,
                "pixelRatio": 2
            },
            "userAgent":
            "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.23 Mobile Safari/537.36"
        }
        return nexus4

    @classmethod
    def createIosDev(cls):
        ip5 = {
            "deviceMetrics": {
                "width": 375,
                "height": 667,