Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UFT IS NOT ABLE TO FIND THE RUNTIMEOBJECT(myo) IN FOR LOOP FOR THE SECOND ITERATION
#1
Not Solved Sad 
Please find the program and attachment
Option explicit 'mandatory to declare a variable before using it

Code:
'declaration of variables
Dim vhvalue,virate,vpmi,vprincipal,vtax,vterm,i,j
Dim vurl,vapp1,vapp2,xpath,xsheet
Dim vpayment1,vpayment2,myo

' fixed variable assignment (paths)used
vurl="C:\Program Files (x86)\Internet Explorer\iexplore.exe"
vapp1="www.mortgagecalculator.org/"
vapp2="http://www.mortgagecalculatorplus.com/"
xpath="E:/QTP_PRACTICE/MORTAGAGEXL.xlsx"
xsheet="MORTAGAGEINPUT"

'loop to repeat the test with different sets of input values

For i = 2 To 7
j=1

virate= myxl_read(xpath,xsheet,i,1)
vpmi=myxl_read(xpath,xsheet,i,2)
vtax=myxl_read(xpath,xsheet,i,3)
vterm=myxl_read(xpath,xsheet,i,4)
vprincipal=myxl_read(xpath,xsheet,i,5)
vpayment1=app1()
vpayment2=app2()
print "result for the iteration" & j & "is" & cmp_fun(vpayment1,vpayment2)

Next
    

Function app1()

'launches browser and opens the app1
systemutil.Run vurl , vapp1

'Sets the  input values into the app1

browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("irate").Set virate
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("pmi").Set vpmi
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("tax").Set vtax
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("term").Set vterm
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("principal").Set vprincipal

'Calculating the result
browser("Mortgage Calculator").Page("Mortgage Calculator").WebButton("Calculate").Click

'Capturing the result

Set myo=description.Create()
myo("htmltag").value="H3"
myo("index").value="1"
****************************************************
app1=browser("Mortgage Calculator").Page("Mortgage Calculator").WebElement("myo").GetROProperty("innertext"
*****************************************************

print  "result of app1" &app1

'Close the mortagage calculator app1
browser("Mortgage Calculator").Close

End Function

wait 3

Function app2()
    
'launches browser and opens the app2
systemutil.Run vurl , vapp2

'Sets the  input values into the app2

browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("irate").Set virate
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("pmi").Set vpmi
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("tax").Set vtax
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("term").Set vterm
browser("Mortgage Calculator").Page("Mortgage Calculator").WebEdit("principal").Set vprincipal

'Calculating the result
browser("Mortgage Calculator").Page("Mortgage Calculator").WebButton("Calculate").Click

'Capturing the result of app2

myo("htmltag").value="H3"
myo("index").value="0"
**************************************************
app2=browser("Mortgage Calculator1").Page("Mortgage Calculator").WebElement("myo").GetROProperty("innertext")
**************************************************
print "result of app2" &app2


'Closing the browser of app2

browser("Mortgage Calculator1").Close

End Function
    
    
    

'Compareing the result of two applications
Function cmp_fun(val1,val2)

If val1=val2 Then
    cmp_fun= "pass"
else
    cmp_fun="fail"
End If
    
End Function


Function myxl_read(xpath,xsheet,xrow,xcol)
    Dim myxlapp,myxlsheet
    
    set myxlapp=createobject("Excel.application")
    myxlapp.Workbooks.Open(xpath)
    set myxlsheet= myxlapp.ActiveWorkbook.Worksheets(xsheet)
    myxl_read=myxlsheet.cells(xrow,xcol)
    
    myxlapp.ActiveWorkbook.Close
    myxlapp.Application.Quit

End Function


Attached Files Image(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Amount for same iteration Rose 1 2,215 03-31-2016, 02:42 PM
Last Post: vinod123
  Infinit loop Suma Parimal 1 2,768 05-29-2014, 01:22 PM
Last Post: basanth27
  Exit Do loop shipu 1 4,896 12-20-2013, 06:33 AM
Last Post: basanth27
Smile Infinite FOR loop issue Sivapratha 3 4,445 04-01-2013, 09:44 AM
Last Post: basanth27
  QTP failure on the last iteration Petey1234 0 1,995 06-15-2012, 12:59 AM
Last Post: Petey1234

Forum Jump:


Users browsing this thread: 1 Guest(s)