QTP中读写xml的组件
来源:互联网 发布:数据结构与算法 pdf 编辑:程序博客网 时间:2024/05/11 16:19
QTP中读写xml可以使用其自带的组件,下面是简单的使用脚本。
''''''The class use to write data for test result report ''''===========Demo to use this class====================='Dim xmlobj'Set xmlobj = new XML'xmlobj.init'xmlobj.add_case 1'xmlobj.add_content 1'xmlobj.add_casename "casename"'xmlobj.add_pagename "pagename"'xmlobj.save "D:\test.xml"''''======================================================Class XMLDim oXML, root, currentcase, currentheader, currentcontentFunction init(file_name)'创建xml保留对象组件set oXML = XMLUtil.CreateXML '新建一个documentSet fso = CreateObject("Scripting.FileSystemObject")If fso.FileExists(file_name) ThenoXML.LoadFile file_name ''''文件存在则读取文件elseoXML.CreateDocument "prodtest" ''''文件不存在则创建根节点End If'获取root根元素set root = oXML.GetRootElement ''''获取根元素End FunctionFunction add_case() '添加一个空的子节点caseroot.AddChildElementByName "case",""int_case_index = root.ChildElements.CountSet currentcase = root.ChildElements.Item(int_case_index)add_header()End FunctionFunction add_header()currentcase.AddChildElementByName "header",""Set currentheader = currentcase.ChildElements.ItemByName("header")End FunctionFunction add_content()currentcase.AddChildElementByName "content",""int_content_index = currentcase.ChildElements.AllItemsByName("content").CountSet currentcontent = currentcase.ChildElements.ItemByName("content", int_content_index)End FunctionFunction add_casename(casename)currentheader.AddChildElementByName "testcase", casename '''''添加带指定内容的子节点End FunctionFunction add_starttime(starttime)currentheader.AddChildElementByName "starttime", starttimeEnd FunctionFunction add_endtime(endtime)currentheader.AddChildElementByName "endtime", endtimeEnd FunctionFunction add_passcount(passcount)currentheader.AddChildElementByName "passcount", passcountEnd FunctionFunction add_failcount(failcount)currentheader.AddChildElementByName "failcount", failcountEnd FunctionFunction add_donecount(donecount)currentheader.AddChildElementByName "donecount", donecountEnd FunctionFunction add_pagename(page)currentcontent.AddChildElementByName "page", pageEnd FunctionFunction add_url(url)currentcontent.AddChildElementByName "url", urlEnd FunctionFunction add_element(element)currentcontent.AddChildElementByName "element", elementEnd FunctionFunction add_function(function_name)currentcontent.AddChildElementByName "function", function_nameEnd FunctionFunction add_reason(reason)currentcontent.AddChildElementByName "reason", reasonEnd FunctionFunction add_detail(detail)currentcontent.AddChildElementByName "detail", detailEnd FunctionFunction add_screen(screen_file)currentcontent.AddChildElementByName "screenshot", "img\"+screen_fileEnd FunctionFunction add_index(int_index)currentcontent.AddChildElementByName "index", int_indexEnd FunctionFunction save(file_name) '保存文件oXML.SaveFile file_name ''''保存文件'释放对象Set root = nothingSet oXML = nothingEnd FunctionEnd Class当然你也可以使用vbs支持的xml组件来读写。比如:Microsoft.XMLDOM。更多关于XMLUtil对象的使用方法请查阅QTP自带帮助文档(Utility.chm)
- QTP中读写xml的组件
- QTP中实现对文本文件(txt)的读写操作
- Qt中xml的读写
- WPF中XML的读写
- QT中XML的读写
- 用QTP调用外部vbs读写XML的例子(一)
- [转]用QTP调用外部vbs读写XML的例…
- QTP---VBS 读取XML中 对应标签的 值
- QTP-实现对文本文件的读写
- QTP-实现对Excel文件的读写
- c#中XML文件的读写操作
- C#中Xml文件的读写问题
- 在c#中XML文件的读写
- C#中XML文件的读写
- WPF中对XML的读写
- Android 中 XmlPullParser 读写 XML 的方法
- WPF中对XML的读写
- WPF中对XML的读写。
- 批处理文件语法
- JAVA套接字(Socket)101七天系列—第三天【一个秘密的套接字】
- velocity的默认配置路径
- FPGA UART TX,简单的FPGA串口发送模块
- MM物料主数据 增强的地方 user-exit MGA00001
- QTP中读写xml的组件
- QLineEdit的应用技术整理
- velocity tools1.x(4)中的handleRequest解析
- 脚本语言简介
- android 截屏
- velocity和spring整合
- mmap详解
- MM发货移动收货MB01/MB1A/MB1C/MB21/MIGO/等用到的user-exitMBCF0002
- 数据库设计的14个技巧