Micro Focus QTP (UFT) Forums
Data table overwrite the value - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Data table overwrite the value (/Thread-Data-table-overwrite-the-value)



Data table overwrite the value - wajahatawan561 - 06-25-2013

Hi there i am trying to capture all the value when i run this script
But when run it the value it captures and insert into the data table. But it captures the values of second vehicle it overwriites the values of 1st vehicle.

Code:
Dim bro, url, image

bro = "iexplore"
url = "http://www.chevrolet.com/tools/help-choose-vehicles.html"

systemutil.Run bro, url
browser("title:=.*").Sync
wait 15

DataTable.GetRowCount    
i=0

Set mypage=browser("title:=.*").page("title:=.*")


While mypage.image("class:=mm size_3","index:="&i).exist
mypage.Sync
wait 3
                                                Datatable( "VehicleName", dtGlobalSheet )= mypage.image("class:=mm size_3","index:="&i).getroproperty("filename")
                                              Datatable( "VehicleName", dtGlobalSheet )= mypage.image("class:=mm size_3","index:="&i).getroproperty("href")
                                                Datatable( "HelpMeChooseMSRP", dtGlobalSheet )= mypage.WebElement("class:=tx_price","index:="&i).getroproperty("innertext")

   mypage.image("class:=mm size_3","index:="&i).click
                mypage.Sync
                wait 4

i=i+1

                Set desc2=description.Create
                  desc2("micclass").value="WebElement"
                  desc2("class").value="parbase ts_attr_c1 section"
                  Set obj2=browser("title:=.*").page("title:=.*").ChildObjects(desc2)
                Datatable( "MSRPonMOPAGE", dtGlobalSheet )=obj2(0).getroproperty("innertext")
                Datatable.SetCurrentRow(i)


Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = False
Datatable.Export("C:\Users\Wajahat.awan\Desktop\Automation\Private DHC\Chevy DHC\Default.xls")
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Wajahat.awan\Desktop\Automation\Private DHC\Chevy DHC\Default.xls")
objWorkbook.SaveAs ("C:\Users\Wajahat.awan\Desktop\Automation\Private DHC\Chevy DHC\MRSP Verify code" & Day(Date) & Month(Date) & Year(Date) & ".xls")
objExcel.Quit

wait 6
     browser("title:=.*").Back
  Wend



RE: Data table overwrite the value - Ankur - 06-25-2013

As mentioned at the top, please ensure to include your code between tags while asking or replying to questions for better readability.


RE: Data table overwrite the value - ssvali - 06-25-2013

Change initial value

i = 1 instead of i = 0