Search code examples
validationvbscripthp-uftbrowser-automation

How to get dialog box text using UFT script?


I am using HP UFT for browser automation in IE browser and here i have one problem i.e Validating the Cards,below are the dialog message will display as per scenario and i need to write if condition based on dialog text,for examples

Scenario texts:

  1. Card is valid for registration
  2. Card No is already registered
  3. Card is blocked
  4. Card is not valid for registration.

All the above dialog box message will comes at one point i.e click on validate card button and please provide one simple script to get that message dynamically in HP UFT .

My Code for Invalid Card number:

Browser("name:=Customer").Dialog("text:=Message from webpage").WinButton("text:=OK").Click
card_number=Browser("name:=Customer").Page("title:=Customer").WebEdit("name:=customerVo.cardNo").GetROProperty("value")
card_status=Browser("name:=Customer").Dialog("text:=Message from webpage").GetROProperty("value")
If card_number="" Then

Reporter.ReportEvent micWarning,"Verify Card Number","Scanned Card number is already registered/Invalid Card Number"
DataTable.value("card_status","customer_enrollment")=card_status
else
Remaining positive script
DataTable.value("card_status","customer_enrollment")=card_status
End If

IN above code i want to print particular scenario message in excel for each records, as based upon card validation status,please help.


Solution

  • For dialogs created by JavaScript's alert, confirm and prompt functions you should use the Browser(".").GetDialogText method.