Micro Focus QTP (UFT) Forums

Full Version: Having problem with Verification
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Req: I need to search customer with first and last name. In return result will be (Last Name Coma Space FirstName). I wrote the follwoing code

Code:
If str_TestCaseId="TC007_PolicySearch_By_FirstAndLastName"  Then
GetReturnedName=Browser(".").Page(".").WebElement(".").GetROProperty("innerhtml")
ReturnedNameFormat= str_LastName&","&" "&str_FirstName

If GetReturnedName=ReturnedNameFormat  Then
Reporter.ReportEvent micPass, "Search returned  proper format of insured name by searching First and last name",""
Reporter.ReportEvent micFail,"Search did not return  proper format of insured name by searching First and last name", ""
End If
End If

As always I belive this forum is the best place to get the solution
I probably will be able to modify the code to suit better but wouldnt guarantee that it will validate the functionality you are looking for. I would request you to elaborate more on what you intend to do?

Code:
If str_TestCaseId="TC007_PolicySearch_By_FirstAndLastName"  Then
GetReturnedName=Browser(".").Page(".").WebElement(".").GetROProperty("innerhtml")
ReturnedNameFormat= str_LastName&","&" "&str_FirstName

If StrComp(Trim(GetReturnedName),Trim(ReturnedNameFormat))>0  Then
    Reporter.ReportEvent micPass, "Search returned  proper format of insured name by searching First and last name",""
Else
     Reporter.ReportEvent micFail,"Search did not return  proper format of         insured name by searching First and last name", ""
End If
End If
Please be aware that if you are not keen on Character casing then you may want to use Ucase or Lcase to format both the strings to a particular case and then perform a Comparision. Because, Strcomp function will fail if the character cases are different.
Awesome! It is like one click solution!!
I have a silly question

In If StrComp(Trim(GetReturnedName),Trim(ReturnedNameFormat))>0 I don't understand >0. =0 would make more sense to me. I tried with =0 but failed. Waiting for your help again.
My mistake and a thousand apologies. It should be,
Code:
StrComp(Trim(GetReturnedName),Trim(ReturnedNameFormat))=0

The result is returned as such,

-1 if Str1 is less than Str2,
1 if Str1 is greater than Str2
0 if the strings are the same.

You may want to try the below to check what is happening with your code,
Code:
msgbox StrComp(Trim(GetReturnedName),Trim(ReturnedNameFormat))=0
This will help you to check which string is greater and what is the reason it is failing.