Micro Focus QTP (UFT) Forums
DataGlobal Sheet - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: DataGlobal Sheet (/Thread-DataGlobal-Sheet)



DataGlobal Sheet - JeanFrederique - 10-29-2009

Hello guys,

I have three different messages in the GlobalSheet that i want my script to run thru and post to my twitter page. I know it should be a FOR loop but have no idea how and where to write it. Can you guys help me? basically, at the end of the script I should have those three message posted on my page.
I created a for loop below and it is bold. when the script is run, it's only posting the first of three messages only. I want it to go tru all three. Please help me.

Thank.



Code:
Browser("Yahoo!").Page("Yahoo!").Sync
Browser("Yahoo!").Navigate "http://www.google.com/"
Browser("Yahoo!").Page("Google").WebEdit("search edit").Set "twitter.com"
Browser("Yahoo!").Page("Google").WebButton("Google Search").Click
Browser("Yahoo!").Page("twitter.com - Google Search").Link("Twitter").Click
Browser("Yahoo!").Page("Twitter").Link("Sign in").Click
Browser("Yahoo!").Page("Twitter").WebEdit("session[username_or_email]").Set "PriMeMiNiSteR"
Browser("Yahoo!").Page("Twitter").WebEdit("password").SetSecure "4ad8967a2b11bd3f6b64a0a0b"
Browser("Yahoo!").Page("Twitter").WebButton("Sign in").Click 0
While (1)
Browser("Yahoo!").Page("Twitter").WebEdit("message").Set DataTable("post", dtGlobalSheet)
[b]Dim rCount
For i = 1 to rCount
rCount= datatable.GetSheet("post").GetRowCount
Next
[/b]
Browser("Yahoo!").Page("Twitter").WebButton("update").Click
Browser("Yahoo!").Page("Twitter").Link("Home").Click

Wend


RE: DataGlobal Sheet - Saket - 10-30-2009

Hi JeanFrederique
Following logic should help you
Code:
'get the row count of global sheet
rCount= datatable.GetSheet(dtGlobalsheet).GetRowCount
'use a for loop to iterate through all rows
For i = 1 to rCount
'set the current row of global sheet
Datatable.SetCurrentRow (i)
'set the message in your web edit
Browser("Yahoo!").Page("Twitter").WebEdit("message").Set DataTable("post", dtGlobalSheet)
Browser("Yahoo!").Page("Twitter").WebButton("update").Click
'Navigate back to your message posting page
Next

alternately you can iterate you message posting statements(only) through all the rows of global sheet by setting 'Run on all rows' at File . Settings, under Run Tab.