QTP: DataTable question

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 @ Friday, November 03, 2006 8:12 AM

Print

Comments on this entry:

# Data Table

Left by shailendra at 12/5/2006 3:35 AM
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

# re: QTP: DataTable question

Left by Theo Moore at 12/5/2006 6:38 AM
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.

# re: QTP: DataTable question

Left by Nageswara Rao at 2/6/2007 7:31 AM
Gravatar
hai shailendra,

remove step 0 and run the program. step 0 doesn't increase the value of the iteration

# re: QTP: DataTable question

Left by SK at 3/15/2007 2:38 PM
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

# re: QTP: DataTable question

Left by Sada at 3/23/2007 7:18 AM
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.

# re: QTP: DataTable question

Left by anil at 3/28/2007 10:55 AM
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

# QTP: DataTable question

Left by Trilok at 5/18/2007 3:30 AM
Gravatar
How to iterate only 10 rows of data from 20 in the DataTable

# QTP: Webex

Left by Aparna at 6/20/2007 2:05 AM
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

# re: QTP: DataTable question

Left by ian at 6/20/2007 10:38 PM
Gravatar
how do you clear values in the datatable during runtime?

# re: QTP: DataTable question

Left by Mamta at 7/10/2007 11:49 PM
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?

# re: QTP: DataTable question

Left by Maryanne Sweat at 7/13/2007 1:52 PM
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.

# re: QTP: DataTable question

Left by Maryanne Sweat at 7/14/2007 10:10 AM
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.

# re: QTP: DataTable question

Left by praveen at 7/20/2007 2:41 AM
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.

# re: QTP: DataTable question

Left by maitreyi at 10/3/2007 1:39 PM
Gravatar
How to get the data from a particular cell of the Data Table?

# re: QTP: DataTable question

Left by sarada chilukuri at 10/16/2007 3:16 PM
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.

# re: QTP: DataTable question

Left by Harish Mulewa at 10/25/2007 8:34 AM
Gravatar
Can we delete a row from QTP Global sheet?

# Need help to import data sheets from XLS file.

Left by Sam at 11/5/2007 12:39 PM
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.

# Sohbet

Left by http://www.sohbetiy.com at 11/23/2007 7:28 AM
Gravatar
http://www.sohbetiy.com

# re: QTP: DataTable question

Left by vikram at 11/27/2007 1:28 AM
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..)

# Kurtlan

Left by Kurtalan at 12/8/2007 6:13 AM
Gravatar
Thanks your, Good job.

# re: QTP: DataTable question

Left by priya at 1/2/2008 6:38 AM
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

# re: QTP: DataTable question

Left by oyular at 1/27/2008 3:30 AM
Gravatar
Thanks your

# re: QTP: DataTable question

Left by ashwin at 1/30/2008 1:41 AM
Gravatar
Hai Everyboy,

Please tell me How to Write Script in QTP for Sanity testing , smoke testing and Regression tesring.

# re: QTP: DataTable question

Left by prasad at 1/31/2008 10:02 AM
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.

# re: QTP: DataTable question

Left by Muhabbet,islami sohbet at 2/7/2008 8:26 AM
Gravatar
muhabbet,islami sohbet

# chat

Left by Ayse can at 2/11/2008 3:12 PM
Gravatar
Thanx Shadow

# re: QTP: DataTable question

Left by Wong Seoul at 2/23/2008 4:53 PM
Gravatar
Thanks for sharing this info. Is there any way I can see this on action..

Thanks

# re: QTP: DataTable question

Left by monica sharma at 2/29/2008 5:02 AM
Gravatar
how can we count the no. of rows of a particular column

# re: QTP: DataTable question

Left by monica sharma at 2/29/2008 5:02 AM
Gravatar
how can we count the no. of rows of a particular column

# re: QTP: DataTable question

Left by doumo_arigatou at 3/6/2008 3:40 AM
Gravatar

# re: QTP: DataTable question

Left by Ponraj at 3/19/2008 3:51 AM
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

# re: QTP: DataTable question

Left by rüya tabirleri at 3/19/2008 3:56 PM
Gravatar
rüyaci tabirleri

# re: QTP: DataTable question

Left by Tracy@Miami at 3/19/2008 7:50 PM
Gravatar
On what DB ?

# re: QTP: DataTable question

Left by kyt.sarasota at 3/25/2008 9:21 AM
Gravatar
Datable comment ->> good blog

# oyunlar

Left by yeni oyunlar at 3/31/2008 8:12 PM
Gravatar
thanx man

# re: QTP: DataTable question

Left by Real Estate at 4/1/2008 9:57 AM
Gravatar
For MySQL ?

# re: QTP: DataTable question

Left by forum at 4/3/2008 2:01 PM
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.

# re: QTP: DataTable question

Left by sohbet odaları at 4/3/2008 2:26 PM
Gravatar
Thanks you very good.

# re: QTP: DataTable question

Left by forum at 4/10/2008 6:35 AM
Gravatar
tihenkis...

# re: QTP: DataTable question

Left by Bistro at 4/15/2008 11:20 AM
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/

# re: QTP: DataTable question

Left by EDV Beratung at 4/15/2008 11:21 AM
Gravatar
THANKS :... :)

# re: QTP: DataTable question

Left by at at 4/29/2008 9:00 PM
Gravatar
hi...can i query the table and import the values to my datatable and compare it with another xls file?

# re: QTP: DataTable question

Left by DivX at 4/30/2008 1:23 PM
Gravatar
No, You can't.

# re: QTP: DataTable question

Left by G.srinivas at 5/6/2008 8:30 AM
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..
Comments have been closed on this topic.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910