将QTP 12结果导出到html会引发错误“样式表不包含文档元素”

时间:2014-07-07 17:26:17

标签: qtp hp-uft

为了生成HTML报告,我试图在下面执行代码。该脚本在" xmlSource.transformNode(xmlXForm)"处抛出错误。错误说"样式表不包含文档元素"。

请帮助。

Function ConvertToHTML(sResultPath)
    'sResultPath = "C:\DOCUME~1\user\LOCALS~1\Temp\TempResults\"
    sProductDir = "C:\Program Files\HP\QuickTest Professional\dat\"
    strOldText = "UTF-16"
    strNewText = "UTF-8"
    Const ForWriting = 2
    Set xmlSource = CreateObject("MSXML.DOMDocument")
    Set xmlXForm = CreateObject("MSXML.DOMDocument")

    xmlSource.validateOnParse = True
    xmlXForm.validateOnParse = True
    xmlSource.async = False
    xmlXForm.async = False

    xmlSource.Load sResultPath & "Report\Results.xml"
    xmlXForm.Load sProductDir & "PShort.xsl" 'if you want more details, then you can use PDetails.xsl
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set fso = CreateObject("Scripting.FileSystemObject")
    sHTMLPath = Replace(sResultPath & "Report\Results.xml", ".xml", ".html")
    Set file = fso.OpenTextFile(sHTMLPath, ForWriting, True)
    file.write xmlSource.transformNode(xmlXForm)
    file.Close

    fso.CopyFile sProductDir & "PResults.css", sResultPath & "Report\"


    Set file = Nothing
    Set fso = Nothing
    Set xmlXForm = Nothing
    Set xmlSource = Nothing

End Function

Call ConvertToHTML("H:\GB_Automation\Res1\")

由于 Bavya

1 个答案:

答案 0 :(得分:0)

您看到的错误通常表示样式表为空或未加载任何内容。仔细检查XSL文件的文件路径是否准确。根据您的代码,您正在尝试从此处加载文件:

C:\Program Files\HP\QuickTest Professional\dat\PShort.xsl

您声明您正在使用" QTP 12",但最后一个版本的QTP是v11。从v11.50开始,它被重命名为Unified Functional Testing。部分重命名意味着默认安装文件夹不再位于" QuickTest Professional"。

我刚刚在64位操作系统上检查了UFT 12的安装,我对同一文件的路径是:

C:\Program Files (x86)\HP\Unified Functional Testing\dat\PShort.xsl

对于32位操作系统,它将是:

C:\Program Files\HP\Unified Functional Testing\dat\PShort.xsl