Beispiel #1
0
    def loadXml(self):
        try:
            tree = xmlHelper.read_xml(self.xmlPath)
            if self.testType == TestType.UI:  #UI测试需要获取hub信息
                connection_nodes = xmlHelper.find_nodes(
                    tree, settings.XML_TAG['testPlan']['connection'])
                if len(connection_nodes) > 0:
                    self.setHubDict(connection_nodes[0])

            scene_nodes = xmlHelper.find_nodes(
                tree, settings.XML_TAG['testPlan']['scene'])
            if len(scene_nodes) > 0:
                self.setSceneList(scene_nodes)
        except Exception as e:
            putSystemLog('[ERROR-0003-0]:解析测试方案配置文件引发的异常.%s' % (e), None, True,
                         RunStatus.END, RunResult.ERROR, True, '异常')
            raise
Beispiel #2
0
    def readParamXml(self, paramPath, className='EasyCase'):
        # 读取参数xml文件的数据
        paramsList = []  # 参数化测试用例的列表

        try:
            tree = xmlHelper.read_xml(paramPath)
            testCase_nodes = xmlHelper.find_nodes(
                tree, settings.XML_TAG['testParam']['testCase'])
            for testCase_node in testCase_nodes:
                testClass_node = xmlHelper.find_nodes(
                    testCase_node, "testClass[@name='EasyCase']")[0]
                params = {}
                for param in testClass_node:
                    id = param.get(settings.XML_TAG['testParam']['id'])
                    if not isNoneOrEmpty(id):
                        value = param.text or ''
                        params[id] = value
                paramsList.append(params)
        except Exception as e:
            raise ReadParamFileException(e)
        return paramsList
Beispiel #3
0
 def setHubDict(self, connection_node):
     if len(self.hubDict) != 0:
         return
     hubDict = {}
     hub_nodes = xmlHelper.find_nodes(connection_node,
                                      settings.XML_TAG['testPlan']['hub'])
     hub_nodes = xmlHelper.get_node_by_keyvalue(
         hub_nodes, {settings.XML_TAG['testPlan']['enabled']: 'True'}, True)
     for hub in hub_nodes:
         browser = hub.get(settings.XML_TAG['testPlan']['browser'])
         if not isNoneOrEmpty(browser):
             remotePath = hub.text.strip() if hub.text is not None else ''
             hubDict[browser.lower().strip()] = remotePath
     self.hubDict = hubDict
Beispiel #4
0
 def getTestCaseListInScene(self, scene_node):
     testCaseList = []
     testCase_nodes = xmlHelper.find_nodes(
         scene_node, settings.XML_TAG['testPlan']['testCase'])
     testCase_nodes = xmlHelper.get_node_by_keyvalue(
         testCase_nodes, {settings.XML_TAG['testPlan']['enabled']: 'True'},
         True)
     # testCase_nodes = [node for node in testCase_nodes if not isNoneOrEmpty(node.text)] #是空的时候,调用内置的测试用例
     for testCase_node in testCase_nodes:
         testCasePath = self.getTestCasePath(testCase_node)
         paramPath = self.getParamPath(testCase_node)
         scriptId = self.getScriptId(testCase_node)
         testCaseList.append({
             'paramPath': paramPath,
             'testCase': testCasePath,
             'scriptId': scriptId
         })
     return testCaseList
Beispiel #5
0
from SRC.common import xmlHelper

tree = xmlHelper.read_xml('uShop.xml')
connection_node = xmlHelper.find_nodes(tree, 'connection')
hub_nodes = xmlHelper.find_nodes(connection_node[0], 'hub1')

node = xmlHelper.get_node_by_keyvalue(hub_nodes, {'enabled': 'True'})
i = 1

# res=xmlHelper.if_match(nodes_scene[0],{'schemeId':'0'})
# print(res)