【问题标题】:Exporting QTP 12 results into html throws the error "The stylesheet does not contain document element"将 QTP 12 结果导出到 html 会引发错误“样式表不包含文档元素”
【发布时间】:2014-07-07 17:26:17
【问题描述】:

为了生成 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\")

谢谢 巴维亚

【问题讨论】:

    标签: qtp hp-uft


    【解决方案1】:

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

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

    您说您使用的是“QTP 12”,但 QTP 的最新版本是 v11。从 v11.50 开始,它被重命名为统一功能测试。部分重命名意味着默认安装文件夹不再位于“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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-13
      • 2016-07-19
      • 2016-09-08
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多