lundi 21 décembre 2015

I am writing a function in HP UFT to compare a validation message in my application to a fixed message. Can anyone help me with the function?

Please point out errors in my code and help me improve it. So far I have written this: 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

Aucun commentaire:

Enregistrer un commentaire