<?xml version="1.0" encoding="UTF-8"?>
<XMLTool>
<DataFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Data.xml</DataFilePath>
<ScenariosFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Scenarios.xml</ScenariosFilePath>
<SelectAllDataPreparationDataRows>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row/@isEnabled</DataRowsXpath>
</SelectAllDataPreparationDataRows>
<RemoveAllEmptyRows>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row</DataRowsXpath>
</RemoveAllEmptyRows>
<AddTheTestURLForAllScenaios>
<Mode>ADDURL</Mode>
<ScenaiorsXpath>//Scenario/@url</ScenaiorsXpath>
<AddedURL>234</AddedURL>
</AddTheTestURLForAllScenaios>
<RemoveScenariosURL>
<ScenariosXpath>//Scenario/@url</ScenariosXpath>
</RemoveScenariosURL>
<SelectAllRegressionScenarios>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/@isEnabled</DataRowsXpath>
</SelectAllRegressionScenarios>
<ChangeOrder>
<TargetScenarioName>RT_Import Entity -AccountCSVError</TargetScenarioName>
</ChangeOrder>
<SelectAllSteps>
<Mode>SELECTALL</Mode>
<ScenariosStepsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/Steps/Step/@isEnabled</ScenariosStepsXpath>
</SelectAllSteps>
<UnSelectAllScenarios>
<ScenariosXpath>//Scenarios/Scenario/@isEnabled</ScenariosXpath>
</UnSelectAllScenarios>
<SelectYourFirm>
<DataRowsXpath>//Table[@name='Login Password']/Rows/Row</DataRowsXpath>
<Name>jack</Name>
</SelectYourFirm>
默认 getroot =XMLTool 所以 第一可以写成 ScenariosFilePath ,默认root 可以省略。
<XMLTool>
<DataFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Data.xml</DataFilePath>
<ScenariosFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Scenarios.xml</ScenariosFilePath>
<SelectAllDataPreparationDataRows>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row/@isEnabled</DataRowsXpath>
</SelectAllDataPreparationDataRows>
<RemoveAllEmptyRows>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row</DataRowsXpath>
</RemoveAllEmptyRows>
<AddTheTestURLForAllScenaios>
<Mode>ADDURL</Mode>
<ScenaiorsXpath>//Scenario/@url</ScenaiorsXpath>
<AddedURL>234</AddedURL>
</AddTheTestURLForAllScenaios>
<RemoveScenariosURL>
<ScenariosXpath>//Scenario/@url</ScenariosXpath>
</RemoveScenariosURL>
<SelectAllRegressionScenarios>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/@isEnabled</DataRowsXpath>
</SelectAllRegressionScenarios>
<ChangeOrder>
<TargetScenarioName>RT_Import Entity -AccountCSVError</TargetScenarioName>
</ChangeOrder>
<SelectAllSteps>
<Mode>SELECTALL</Mode>
<ScenariosStepsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/Steps/Step/@isEnabled</ScenariosStepsXpath>
</SelectAllSteps>
<UnSelectAllScenarios>
<ScenariosXpath>//Scenarios/Scenario/@isEnabled</ScenariosXpath>
</UnSelectAllScenarios>
<SelectYourFirm>
<DataRowsXpath>//Table[@name='Login Password']/Rows/Row</DataRowsXpath>
<Name>jack</Name>
</SelectYourFirm>
</XMLTool>
import xml.etree.ElementTree as ET
import os
def getXMLConfigNodeText(filePath,xPath):
if (os.path.isfile(filePath)==False):
return;
root=ET.parse(filePath).getroot();
nodetext=root.find(xPath).text
if (nodetext==""):
print("please check the node name is right!")
#print(nodetext)
return nodetext
import ReadXmlConfig
if __name__ == '__main__':
scenarioFilePath=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml","ScenariosFilePath")
xpath=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml","AddTheTestURLForAllScenaios/ScenaiorsXpath")
url=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml", "AddTheTestURLForAllScenaios/AddedURL")
print(scenarioFilePath)
print(xpath)
print(url)
默认 getroot =XMLTool 所以 第一可以写成 ScenariosFilePath ,默认root 可以省略。