Posts: 2
Threads: 1
Joined: Apr 2011
Reputation:
0
04-12-2011, 12:32 PM
Hi,
I've got a DataTable and I need the script to search the DataTable, find a value in a particular column that matches the condition and retrieve a row number of that row which contains the searched value and run 1 iteration on the row number retrieved.
Example, I want to run test on row which contains value = E in col2, so the result should be row number = 2
col1 col2 col3
A B C
D E F
G H I
Posts: 3
Threads: 0
Joined: Apr 2011
Reputation:
0
04-12-2011, 12:44 PM
(This post was last modified: 04-12-2011, 12:44 PM by Shrikantsr.)
Hi,
you can run a For loop for the same purpose....Flow will be like this:
1.First get row count of the excel sheet with GetRowCount method.
2.Store it in a variable say Row_Count.
3.Run a For loop say "For i=1 to Row_Count
4.get the value of Coumn2 by "DataTabe.Value" method and store it in a variable say "Temp"
5.Compare the value Temp wiht value"E" and now u can run your test case accordinly...
Hope it will be helpful..........
Regards
Posts: 3
Threads: 0
Joined: Apr 2011
Reputation:
0
04-12-2011, 02:08 PM
You can jump out of For loop once you are getting the expected value i.e "E" for you like this:
If temp="E" Then Exit For
Regards
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
04-12-2011, 07:30 PM
Woah..not a advisable method to go with a webtable. This is a method which gets confused if it finds an E in any other row and will simply mislead you into a trap. Kind of a blind method when you have a webtable with minimal rows and not many conflicting data. Better to avoid this method.
It is always advisable to loop through a webtable, retrieve the value, compare against your expected and when matched
Exit the loop.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.