用于将验证消息与固定消息进行比较的功能

时间:2015-12-22 06:06:16

标签: testing automated-tests qtp hp-uft

我正在HP UFT中编写一个函数来将我的应用程序中的验证消息与固定消息进行比较。任何人都可以帮我解决这个问题吗?

请在我的代码中指出错误并帮助我改进它。

到目前为止,我已经写过:

Sub fnCaptureTextandCompare(objPage,oWebElement,ObjectName)

    If objPage.WebElement(oWebElement).Exist(10) Then
        strActualError = objPage.WebElement(oWebElement).getroproperty("innertext")
        strExpectedError = DataTable.Value(Parameter1,"Data")
        Call fnCompare(strExpectedError,strActualError,ObjectName)      
    Else
        Reporter.ReportEvent micFail,"fnCaptureTextandCompare","Webelement '"&ObjectName&"' does not exist" 
    End if
End Sub

Sub fnCompare(Expected_Value,Actual_Value,FieldName)

        If Expected_Value = Actual_Value Then
            Reporter.ReportEvent micPass,"fnCompare:","Field:'"&FieldName&vbcrlf&" Expected= '"&Expected_Value&"'"&vbcrlf&"Actual= '"&Actual_Value&"'"
        Else
            Reporter.ReportEvent micFail,"fnCompare:","Field:'"&FieldName&vbcrlf&" Expected= '"&Expected_Value&"'"&vbcrlf&"Actual= '"&Actual_Value&"'"
        End If  
End Sub

0 个答案:

没有答案