Micro Focus QTP (UFT) Forums
how to validate combobox values with testdata values - 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: how to validate combobox values with testdata values (/Thread-how-to-validate-combobox-values-with-testdata-values)



how to validate combobox values with testdata values - 1981.madhu@gmail.com - 09-09-2009

I have one combobox ,having values like value1,value2...this is displaying at UI,i want to validate this values with my Expected values(Testdata).My code is like

Code:
val=window("").wincombobox("").getitemscount

for i=0 to val-1

d=window("").wincombobox("").getitem(i)

s=s+d+vbnewline
print s

watever values in the combobox all values dispaly in the window.
Now i want to compare these values with my testdata values.These test data values in the textfile like val1,val2 ,val3 like
How can i compare and report my results.Pls give me the code


RE: how to validate combobox values with testdata values - Saket - 09-09-2009

You can try this
Code:
Set fso=createObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(YourFilePath, 1)
Dim strLine, arrLine, bMatch
if f.AtEndOfStream <> True
            strLine = f.ReadLine
            arrLine = split(strLine,",")
end if

val=window("").wincombobox("").getitemscount

bMatch = 0
for i= 0 to val-1
    d=window("").wincombobox("").getitem(i)
    if d = arrLine(i) Then bMatch = 1
Next

If bMatch = 1 then
    Msgbox "Compare - Failed"
Else
    Msgbox "Compare - Passed"
End if

I am assuming you have values in the text file in the form "Val1,Val2,.."
let me know if it works..


RE: how to validate combobox values with testdata values - 1981.madhu@gmail.com - 09-09-2009

In combobox i have values -India
USA
London
Japan
In my textfile having--India1,USA1,London,Japan
After Executing above code (urs).iam getting msg Has "Compare pass",but i given the wrong values in the textfile,y its like ..if i give right values ,then also its giving same .


RE: how to validate combobox values with testdata values - Saket - 09-09-2009

Sorry my mistake, Can you please correct this statement in the above code and try again
Code:
if d <> arrLine(i) Then bMatch = 1