Reputation: 1
How can I set up the if statement so that QTP will display Passed or Failed if conditions met. Currently I have the properties of a valid coupon and invalid coupon. Each will display a different message on the website. Please see the code below:
Set objBrowser = Browser("name:=.*Chico's")
Set objPage = objBrowser.Page("title:=.*Chico's")
Dim x
x=datatable.GetSheet("Global").GetRowCount
'-----for loop---------
For i = 1 To x Step 1
Datatable.SetCurrentRow(i)
objPage.WebEdit("html tag:=INPUT","html id:=claimCodeField","name:=claimCodeField").Set datatable ("Coupon_code", GlobalSheet)
wait 2
objPage.Image("name:=CouponFormHandler","html tag:=INPUT","image type:=Image Button","file name:=btn_apply\.gif").Click
wait 2
objBrowser.Sync
Dim Coupon, Couponerror
xlCoupondescription=dataTable ("Coupon_description", GlobalSheet)
xlInvalid=dataTable("Invalid_coupon", GlobalSheet)
'----Coupon----
Coupon=objPage.WebElement("class:=sb-promo-msg","html tag:=SPAN","html id:=","Index:=1").GetROProperty("outertext")
'----Coupon Error msg-----
Couponerror=objPage.WebElement("class:=sb-error-message","html tag:=DIV","html id:=").GetROProperty("outertext")
'----if statement---------
If (Trim(Coupon) = Trim(xlCoupondescription)) Then
datatable.value("Actual_results", GlobalSheet)="Passed"
If (Trim(Coupon) = Trim(Couponerror)) Then
datatable.value("Actual_results", GlobalSheet)="Failed"
End If
End If
Upvotes: 0
Views: 279
Reputation: 1243
Use the Reporter.ReportEvent
method when you want to report custom pass/fail conditions.
Upvotes: 2