Geeks With Blogs
Theo Moore Questions... Morphology? Longevity? Incept dates?

A gentleman recently sent me an e-mail asking a question about DataTables:

 

1. Why DataTable.GetRowCount and DataTable.GetCurrentRow are not working properly in some of the tests scripts, 2. here the values are placed into the datatable from the weblist during the runtime.... is it becoz of that or any other settings required to retrieve the rowscount in the test thank u in advance

I suspect the problem might be an issue with the Global vs. Local sheet, so I have replied with the following:
Hi! It's difficult to say why GetRowCount and GetCurrentRow aren't working, but here's what I would check: Is the data located in the Global or a different sheet? The methods for the DataTable default to using the Global sheet. In order to use those for other sheets, I find it easiet to grab the sheet specifically like this:
Dim oSheet
Set oSheet = DataTable.GetSheet("ActionName") 'I can use the methods using oSheet msgbox oSheet.GetRowCount

Populating the DataTable dynamically should be fine; you should be able to use GetRowCount anytime and get the correct number of rows. I tend to avoid using the DataTable, but I have never really seen the GetRowCount/GetCurrentRow not give accurate results when I ask for the right parts. I have created an example to illustrate what I mean. Create a new test and add two Actions. Place Data (10 rows in my example) in the Global sheet in column A, and similar Data (5 rows in my example) in the Action1 sheet, but a different number of rows. Then add the code to the correct action:

'Action1 code

DataTable.SetCurrentRow(11)
'Since we are pointed to the DataTable, it assumes global DataTable("A", dtGlobalSheet) = "11" 'We change the value in the the 11th row

'Action2 code
Dim oTable
Set oTable = DataTable.GetSheet("Action1")
msgbox datatable.GetRowCount
msgbox oTable.GetRowCount
msgbox DataTable.GetRowCount

If you run this, you'll see that oTable.GetRowCount gives you the Action1 count, and DataTable.GetRowCount gives you the global. If this isn't the problem, then I'd contact Support. Hope this is helpful.
Theo Posted on Friday, November 3, 2006 8:12 AM | Back to top


Comments on this post: QTP: DataTable question

# Data Table
Requesting Gravatar...
Hello,
I have written the script as,
DataTable.Import("G:\text1.xls")
DataTable.SetCurrentRow("1")
For login_id = 1 to 4 step 0
a=DataTable.Value("login_id")
msgbox a
DataTable.SetNextRow
Next

When i run this script it shows the data one by one but it iterates for four times,i want it to run only one time i.e just show the data and stop running
Left by shailendra on Dec 05, 2006 3:35 AM

# re: QTP: DataTable question
Requesting Gravatar...
Hi! I'd check the Test, Settings options. The Run tab on your Test Settings dialog has some options about how to iterate the data table. I'd select run one iteration only; that way you can control the use of the datatable. Hope this helps.
Left by Theo Moore on Dec 05, 2006 6:38 AM

# re: QTP: DataTable question
Requesting Gravatar...
hai shailendra,

remove step 0 and run the program. step 0 doesn't increase the value of the iteration
Left by Nageswara Rao on Feb 06, 2007 7:31 AM

# re: QTP: DataTable question
Requesting Gravatar...
I have a question. could anyone help me with this.
When iam running a test script , it takes values from the first row of the datatable and showing the test result, without executing all the iterations by taking values from other rows. What could be the possible reason for this
Left by SK on Mar 15, 2007 2:38 PM

# re: QTP: DataTable question
Requesting Gravatar...
Check the Action Call Properties for that action by right clicking Action from Keyword View , there it might be "Run One Iteration Only" option selected.
Left by Sada on Mar 23, 2007 7:18 AM

# re: QTP: DataTable question
Requesting Gravatar...
hi,how to count the columns.getrow is used to count no.of rows.so for counting no.of columns,pls tell me how to do.pls send mail to svrakumar@yahoo.co.in....Urgent.pls
Left by anil on Mar 28, 2007 10:55 AM

# QTP: DataTable question
Requesting Gravatar...
How to iterate only 10 rows of data from 20 in the DataTable
Left by Trilok on May 18, 2007 3:30 AM

# QTP: Webex
Requesting Gravatar...
Hi could anyone tell whether we could record runtime QTP scripts, as like we do WEBEX(i'm aware of the QTP test-run results- snapshots, but all i wanted to know is live recording like in Webex)
Thanks in advance
Left by Aparna on Jun 20, 2007 2:05 AM

# re: QTP: DataTable question
Requesting Gravatar...
how do you clear values in the datatable during runtime?
Left by ian on Jun 20, 2007 10:38 PM

# re: QTP: DataTable question
Requesting Gravatar...
Any idea guys how to clear contents of a row in a datatable if it contains some data .
I have a table where I don want to append data but reset it.
if in my datatable
login id =mamta123 and pwd =1234 then next time it is adding data to it
login id=mamta123shirley123
any idea?
Left by Mamta on Jul 10, 2007 11:49 PM

# re: QTP: DataTable question
Requesting Gravatar...
You should be able to do a simple DataTable("FIELD_1", dtLocalSheet) = newvariablevalue or DataTable("FIELD_1", dtLocalSheet) ="insert text here" to change the field value at runtime.
I have several scripts where I do this and it seems to work just fine. If you did DataTable("FIELD_1", dtLocalSheet)=DataTable("FIELD_1", dtLocalSheet) & "newtext" it would append values to your field in the datasheet.
Left by Maryanne Sweat on Jul 13, 2007 1:52 PM

# re: QTP: DataTable question
Requesting Gravatar...
Yes that's quite possible too. I'm sorry I didn't see that the wanted to clear an entire row. <ponders getting her eyes checked>
If you need to reset data on an entire row, a resusable component which iterates over each column is a good option. I am not sitting in front of my QTP install at the moment so I don't know if there is a Row.clear command.
Left by Maryanne Sweat on Jul 14, 2007 10:10 AM

# re: QTP: DataTable question
Requesting Gravatar...
Can any one tell me, How to write a script to access Object repository in QTP. In that , i want to check how many objects are present and i want access each object text property one by one.
Left by praveen on Jul 20, 2007 2:41 AM

# re: QTP: DataTable question
Requesting Gravatar...
How to get the data from a particular cell of the Data Table?
Left by maitreyi on Oct 03, 2007 1:39 PM

# re: QTP: DataTable question
Requesting Gravatar...
Hi
iam using a datatable iterations.after the iterations are done i want the script to stop running.it is not doing so.
i have selected the Run options as one iteration only.
its running the invoke application several times.
Left by sarada chilukuri on Oct 16, 2007 3:16 PM

# re: QTP: DataTable question
Requesting Gravatar...
Can we delete a row from QTP Global sheet?
Left by Harish Mulewa on Oct 25, 2007 8:34 AM

# Need help to import data sheets from XLS file.
Requesting Gravatar...
Hi,

I have a test script that uses all reusable functions. The same
test script can use different set of data for different test
environments. Different sets data for the test environments are in
several XLS files.

For example:
test script = DO_SANITY_TEST (made of several reusable functions)
data for env 1 = C:\QTP\data\env1\SANITY.xls
data for env 2 = C:\QTP\data\env2\SANITY.xls and so on.

Need to:
For env 1, need to import the data-sheets from ...\env1\SANITY.xls
env 2, need to import the data-sheets from ...\env2\SANITY.xls
and so on...

Looked used DataTable.Import (<filename>) but am still confused because it does not work.
Left by Sam on Nov 05, 2007 12:39 PM

# re: QTP: DataTable question
Requesting Gravatar...
Would be great if you could please let me know

"how can I get the number of rows of a particular column of a datatable(global or Local) during the runtime..?

(I know that GetRowcount will give us the no.of rows of longest column..)
Left by vikram on Nov 27, 2007 1:28 AM

# re: QTP: DataTable question
Requesting Gravatar...
hi.... i am testing a website ,i ve some value in webpage(ex:some fields).i ve to automatically update or compare these values in excel files.....
please give sample script in qtp...
if knows thn pls mail to :glpriyaram@rediffmail.com
Left by priya on Jan 02, 2008 6:38 AM

# re: QTP: DataTable question
Requesting Gravatar...
Thanks your
Left by oyular on Jan 27, 2008 3:30 AM

# re: QTP: DataTable question
Requesting Gravatar...
Hai Everyboy,

Please tell me How to Write Script in QTP for Sanity testing , smoke testing and Regression tesring.
Left by ashwin on Jan 30, 2008 1:41 AM

# re: QTP: DataTable question
Requesting Gravatar...
Hi all

I have recorded few application actions and i parametrised that action by using ddt functionality in QTP,data table is .xls which i will import from my local machine while executing script.

while executing that scripts, always script is taking first row details only, but no.of itration are same as no.of rows which i have mentioned in data table.

for example:
I have mentioned data in three rows
i.e one row will cover one scenario,second row will cover second scenario and third row for third scenario

but my script is executing three times with first row data only, it is not taking second and third row data.

pls advice whate could be the reason.
Left by prasad on Jan 31, 2008 10:02 AM

# re: QTP: DataTable question
Requesting Gravatar...
Thanks for sharing this info. Is there any way I can see this on action..

Thanks
Left by Wong Seoul on Feb 23, 2008 4:53 PM

# re: QTP: DataTable question
Requesting Gravatar...
how can we count the no. of rows of a particular column
Left by monica sharma on Feb 29, 2008 5:02 AM

# re: QTP: DataTable question
Requesting Gravatar...
how can we count the no. of rows of a particular column
Left by monica sharma on Feb 29, 2008 5:02 AM

# re: QTP: DataTable question
Requesting Gravatar...
hi all,
i want to know one thing in QTP data table. Is ther any option to parameterize a link in the apllicatiopn..
pl give me the solutions on that

Thanks
Ponraj S
Left by Ponraj on Mar 19, 2008 3:51 AM

# re: QTP: DataTable question
Requesting Gravatar...
Datable comment ->> good blog
Left by kyt.sarasota on Mar 25, 2008 9:21 AM

# re: QTP: DataTable question
Requesting Gravatar...
For MySQL ?
Left by Real Estate on Apr 01, 2008 9:57 AM

# re: QTP: DataTable question
Requesting Gravatar...
You should be able to do a simple DataTable("FIELD_1", dtLocalSheet) = newvariablevalue or DataTable("FIELD_1", dtLocalSheet) ="insert text here" to change the field value at runtime.
I have several scripts where I do this and it seems to work just fine. If you did DataTable("FIELD_1", dtLocalSheet)=DataTable("FIELD_1", dtLocalSheet) & "newtext" it would append values to your field in the datasheet.
Left by forum on Apr 03, 2008 2:01 PM

# re: QTP: DataTable question
Requesting Gravatar...
Thanks you very good.
Left by sohbet odaları on Apr 03, 2008 2:26 PM

# re: QTP: DataTable question
Requesting Gravatar...
THANKS :::: NICE ::: THANKS

do you know ?

Submit Searchengines for Free ?

http://www.us-ranking.de/

for xxx sites look

http://www.xxx-webdirectory.de/

Left by Bistro on Apr 15, 2008 11:20 AM

# re: QTP: DataTable question
Requesting Gravatar...
THANKS :... :)
Left by EDV Beratung on Apr 15, 2008 11:21 AM

# re: QTP: DataTable question
Requesting Gravatar...
hi...can i query the table and import the values to my datatable and compare it with another xls file?
Left by at on Apr 29, 2008 9:00 PM

# re: QTP: DataTable question
Requesting Gravatar...
No, You can't.
Left by DivX on Apr 30, 2008 1:23 PM

# re: QTP: DataTable question
Requesting Gravatar...
Hi,
i imported data into data table which consists of 6 rows.Next succeding iteration is not executed if any one of the vaule in particular row is incorrect (say ex: 2 row).i.e Displaying results without 3 row tested .
Please help me very urgent..
Left by G.srinivas on May 06, 2008 8:30 AM

Your comment:
 (will show your gravatar)


Copyright © Theo Moore | Powered by: GeeksWithBlogs.net | Join free