Hi Christian,
It seems the excel objects are distroying and in the very fist iteration of
the or loop.
Please make object nothing outside of for loop like
*Set* myExcel = *CreateObject*("Excel.Application")
*Set* myworkbook =
myExcel.Workbooks.Open("C:\Users\christian.sanchez\Desktop\QTP
Automation\Ecom_QTP_Scripts\Promo_Automation\TestResults\Automation_Results_Coupons.xlsx"
)
*Set* myworksheet = myworkbook.Worksheets("Results CHS")
*dim* testDescription, Qualify, Error1, error2, RowsCount, myExcel,
myworkbook, myworksheet
RowsCount=myworksheet.usedrange.rows.count
*For* i = 3 *to* RowsCount *Step* 1
….your code logic
*Next*
myExcel.DisplayAlerts = *false*
myworkbook.save
myExcel.DisplayAlerts = *true*
myExcel.Quit
*Set* myworksheet=*nothing*
*Set* myworkbook=*nothing*
*Set* myExcel=*nothing*
Please try it.
On Tue, Jan 27, 2015 at 4:23 PM, Christian Sanchez <
[email protected]> wrote:
>
> Hello,
>
> I need help. I have 5 scenarious in an excel sheet and using a For loop to
> iterate through each one. The problem is that the loop is not looping. It
> only keeps looping the first row and does not continue with the others.
> Here's my code:
>
> Set myExcel = CreateObject("Excel.Application")
> Set myworkbook =
> myExcel.Workbooks.Open("C:\Users\christian.sanchez\Desktop\QTP
> Automation\Ecom_QTP_Scripts\Promo_Automation\TestResults\Automation_Results_Coupons.xlsx"
> )
> Set myworksheet = myworkbook.Worksheets("Results CHS")
>
> dim testDescription, Qualify, Error1, error2, RowsCount, myExcel,
> myworkbook, myworksheet
>
> RowsCount=myworksheet.usedrange.rows.count
>
> For i = 3 to RowsCount Step 1
>
>
> objPage.WebEdit("html tag:=INPUT","html id:=claimCodeField",
> "name:=claimCodeField").Set myworksheet.cells(i,"B")
> wait 2
> objPage.Image("name:=CouponFormHandler","html tag:=INPUT","image
> type:=Image Button","file name:=btn_apply\.gif")
> .Click
> wait 2
>
> On Error Resume Next
> 'Coupon = ""
> Coupon=objPage.WebElement("class:=sb-promo-msg","html tag:=SPAN","html
> id:=","Index:=1").GetROProperty("outertext")
> Invalidcoupon = objPage.WebElement("class:=sb-error-message","html
> tag:=DIV").GetROProperty("outertext")
> objBrowser.Sync
> Print (coupon)
> 'Print (Invalidcoupon)
>
> testDescription = myworksheet.cells(i,"C").value
> Qualify = myworksheet.cells(i,"D")
> Error1 = myworksheet.cells(i,"E")
> Error2 = myworksheet.cells(i,"F")
> CouponCode = myworksheet.cells(i,"B")
>
> If (trim(Coupon = testdescription)) or (trim(Coupon = Qualify)) Then
> Call Results(Coupon,"Passed",CouponCode)
> Reporter.ReportEvent micPass,"Coupon", Coupon
> ElseIf (trim(Invalidcoupon = Error1)) or (trim(Invalidcoupon = Error2
> )) Then
> Call Results(Coupon,"Failed",CouponCode)
> Reporter.ReportEvent micFail,"Invalidcoupon", Invalidcoupon
>
> End If
> objBrowser.Sync
>
> '*****REMOVED LINK*****
>
> objpage.link("class:=sbPromoRemove","html tag:=A","name:=Remove",
> "text:=Remove","outertext:=Remove","Index:=1").Click
>
>
> myExcel.DisplayAlerts = false
> myworkbook.save
> myExcel.DisplayAlerts = true
> myExcel.Quit
> Set myworksheet=nothing
> Set myworkbook=nothing
> Set myExcel=nothing
>
> Next
>
> --
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "QTP - HP Quick Test Professional - Automated Software Testing" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
---
You received this message because you are subscribed to the Google Groups "QTP
- HP Quick Test Professional - Automated Software Testing" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.