If statement 对运行时对象使用if语句的QTP

If statement 对运行时对象使用if语句的QTP,if-statement,qtp,hp-uft,If Statement,Qtp,Hp Uft,如何设置if语句,以便在满足条件时,QTP将显示Passed或Failed。目前我拥有有效优惠券和无效优惠券的属性。每个人都会在网站上显示不同的信息。请参阅下面的代码: Set objBrowser = Browser("name:=.*Chico's") Set objPage = objBrowser.Page("title:=.*Chico's") Dim x x=datatable.GetSheet("Global").GetRowCount '-----for loop------

如何设置if语句,以便在满足条件时,QTP将显示Passed或Failed。目前我拥有有效优惠券和无效优惠券的属性。每个人都会在网站上显示不同的信息。请参阅下面的代码:

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

如果要报告自定义通过/失败条件,请使用
Reporter.ReportEvent
方法