프로젝트 자동화 테스트 구조에 대한 개량 계획 - 내용 파일 동작 지령 정보
내부 반복 해석에 대한 코드는 다음과 같습니다.
/**
* add the new information which configured in original xml and finally generate the new xml
*/
publicstaticString addElementToXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the add information are provided by XMLModifyInfoExtractor
List addElementInfoList = extractor.getAddElementInfoList();
List nodes ;
for(AddElement addElement : addElementInfoList){
String testcaseXPath =addElement.getTestcaseXPath();
String path =addElement.getPath();
String value=addElement.getValue();
//make the value as a Element block
Element newElementSnippet = DocumentHelper.parseText(value).getRootElement();
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
//node.getParent().remove(node);
//node.setText(value);
Element addingPointElement = (Element) node;
addingPointElement.add(newElementSnippet);
}
}
}
returndoc.asXML();
}
내부 요소를 반복하는 코드는 다음과 같습니다.
/**
* update the information which configured in original xml and finally generate the new xml
*/
publicstaticString updateElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the update information are provided by XMLModifyInfoExtractor
List updateElementInfoList = extractor.getUpdateElementInfoList();
List nodes ;
for(UpdateElement updateElement : updateElementInfoList){
String testcaseXPath =updateElement.getTestcaseXPath();
String path =updateElement.getPath();
String value=updateElement.getValue();
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
node.setText(value);
}
}
}
returndoc.asXML();
}
에서 요소를 반복 해석하는 코드는 다음과 같습니다.
/**
* remove the information which configured in original xml and finally generate the new xml
*/
publicstaticString removeElementFromXML(String xmlString ,XMLModifyInfoExtractor extractor,String originalFilePath) throwsException{
Document doc = null;
doc = DocumentHelper.parseText(xmlString);
extractor.extractModifyInfo(originalFilePath);
//All the remove information are provided by XMLModifyInfoExtractor
List removeElementInfoList = extractor.getRemoveElementInfoList();
List nodes ;
for(RemoveElement removeElement : removeElementInfoList){
String testcaseXPath =removeElement.getTestcaseXPath();
String path =removeElement.getPath();
nodes = doc.selectNodes(path);
for(Node node :nodes){
//if in the node is in matching testcase ,then remove it
String nodeUniquePath = node.getUniquePath();
if(nodeUniquePath.indexOf(testcaseXPath) !=-1){
node.getParent().remove(node);
}
}
}
returndoc.asXML();
}
마지막으로 3단계 동작 시리즈를 실행한 후에 최종 xml 파일은 최종적으로 우리가 수정한 결과를 포함합니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
QTP 패키징 쉬운 함수1. 역할: 브라우저를 선택하여 지정된 웹 페이지를 엽니다. 매개 변수:strType 브라우저 openUrl 웹 페이지 열기 2. 역할: 페이지 새로 고침(QTP 자체 Refresh 함수)...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.