How to match data of a table and list box using QTP? Pls answer immidiately.
Hi,
I'm testing an web application using QTP9.0.in a page of application containing various listboxes with data and some editable blank text fields with an ADD button. After giving all valid values and clicking add button allthese given data is displayed in a table format under their respective columns in another web page. Please tell me how to match these column and cell values with the given data using QTP9.0?
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
Dim a(<<number of Item s u are adding>>)
''Hold all the to be added Item in the Array/ Use the ListBox Entires at RunTime.
intCnt = Browser(b).Page(p).Frame(f).WebList(W).getROProperty("items count")
''Once u have added the Items Using the Add Functionality (Comparision?)
For LCnt = 0 to intCnt-1
'''Hold the Data from the Table
strTMP = Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(LCnt +1,1)
''Assuming that the added data is reflected in the First Column
if strComp(strTMP,a(LCnt) = 0 then
Reporter.ReportEvent micPass,"SUCCESS","SUCESS"
else
Reporter.ReportEvent micFail,"FAILURE","FAILURE"
end if
Next
Regards,
Nawab
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
You can verify the added data in listbox using getcelldata method.
example:
say you added 3 data fields(x1,x2,x3) in the page and click on add button.Then you have verify the added data i.e. x1,x2,x3 in listbox in next page. for this
get the 1st column data of added row and verify with x1.
xx=Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(1,1)
if xx=x1 then
reporter.reportevent micpass,"pass","verified"
else
reporter.reportevent micFail,"Failed","Not verified"
end if
same way you verify for the next two data fields.
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
[QUOTE=NawabShaikh;29094]Dim a(<<number of Item s u are adding>>)
''Hold all the to be added Item in the Array/ Use the ListBox Entires at RunTime.
intCnt = Browser(b).Page(p).Frame(f).WebList(W).getROProperty("items count")
''Once u have added the Items Using the Add Functionality (Comparision?)
For LCnt = 0 to intCnt-1
'''Hold the Data from the Table
strTMP = Browser(b).Page(p).Frame(f).WebTable(w).GetCellData(LCnt +1,1)
''Assuming that the added data is reflected in the First Column
if strComp(strTMP,a(LCnt) = 0 then
Reporter.ReportEvent micPass,"SUCCESS","SUCESS"
else
Reporter.ReportEvent micFail,"FAILURE","FAILURE"
end if
Next
Regards,
Nawab[/QUOTE]
Hi Nawab,
Thanks For ur reply, But this script program is not working for my appliction. Can you simplify it a bit please.
Warm Regards,
Sunita
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
Store the added data in an array
dim data_added
data_added=array("x1","x2",x3")
'verify the data in the listbox
for i=1 to 3
data_list=Browser("Listbox").Page("Listbox").Frame("AppWindow").WebTable("Name").GetCellData(1,i)
if data_list=data_added(i)
msgbox "pass"
else
msgbox "fail"
end if
next
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
Nested Loop is required...
1.Outer one to traverse for Weblist(Combobox arrays entry)
2.Inner one to traverse for each of the WebTable row.
if this doesn't solve the purpose please revert with specs, I will help with the complete code.
:)
Regards,
Nawab
Re: How to match data of a table and list box using QTP? Pls answer immidiately.
[QUOTE=amarvreddy20;29421]Store the added data in an array
dim data_added
data_added=array("x1","x2",x3")
'verify the data in the listbox
for i=1 to 3
data_list=Browser("Listbox").Page("Listbox").Frame("AppWindow").WebTable("Name").GetCellData(1,i)
if data_list=data_added(i)
msgbox "pass"
else
msgbox "fail"
end if
next[/QUOTE]
Hi Nawab the above script works well for few items, but if the webtable or weblist contains more items like 100+ then how to modify the script.
Is it possible to put the items in Excel and compare the web tbale items/weblist items with that excel sheet ?
If yes can you please help me.
Thanks