Micro Focus QTP (UFT) Forums
Having problem with Verification - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Having problem with Verification (/Thread-Having-problem-with-Verification)



Having problem with Verification - qapandit - 07-24-2013

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


RE: Having problem with Verification - basanth27 - 07-25-2013

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.


RE: Having problem with Verification - qapandit - 07-25-2013

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.


RE: Having problem with Verification - basanth27 - 07-26-2013

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.