Micro Focus QTP (UFT) Forums
How To Find Dropdown Object based on Values from the dropdown list - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How To Find Dropdown Object based on Values from the dropdown list (/Thread-How-To-Find-Dropdown-Object-based-on-Values-from-the-dropdown-list)

Pages: 1 2


RE: How To Find Dropdown Object based on Values from the dropdown list - vijaychourasiya0109@gmail.com - 09-14-2017

(05-18-2012, 06:29 PM)mesg2anil Wrote: Hi,

I'm having difficulty scripting for below situation...

I have a dropdown list, in the dropdown list I've values as below...
one
two
three
four
five

I want to find the dropdown object exists or not based on the dropdown list values as shown above. How to find the object? Please help!!

Regards,
Anil

Hi you can use the Excel,You can matching the value with application drop down value to Excel input value:

Function DropDownValidation(Str_ExcelPath)
    
Str_ExcelPath= "C:\Users\chvijay\Desktop\SDB_Dropdwon list_5.0.xlsx"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.WorkBooks.Open(Str_ExcelPath)
Set objDriverSheet = objWorkbook.Worksheets("witholding-tax-code")
count_rows=objDriverSheet.usedrange.rows.count
 DropDownItems=Browser("INTEGRATION").Page(INTEGRATION").WebList("frm:tabView:integratedLocalAcc_5").GetROProperty("all items")
 Str_Result=split(DropDownItems,";")

For i = 0 To UBound(Str_Result) Step 1
    finelresult=Str_Result(i)
    finelresult1=finelresult1&" "&finelresult
    Next
    print "Item In Drob Down"&"-"&finelresult1
        For j= 2 To count_rows Step 1
        read_Value_Excel= objDriverSheet.cells(j,1).value
         print "ReadValue From Excel"&" "&read_Value_Excel

        If ucase(trim(instr(finelresult1,read_Value_Excel)>0))Then
            objDriverSheet.cells(j,5)="Available"
            DropDownValidation=true
         else

            objDriverSheet.cells(j,5)="Not Available"
            'MsgBox "Not Write"
           DropDownValidation=False
        End If
    Next
    
    objWorkbook.Save
    wait 2
    objExcel.Quit


RE: How To Find Dropdown Object based on Values from the dropdown list - supputuri - 10-03-2017

I would use Instr method to find out if the list item present in the list or not.

Code:
DropDownItems=Browser("INTEGRATION").Page(INTEGRATION").WebList("frm:tabView:integratedLocalAcc_5").GetROProperty("all items")
DropDownItems = ";" & DropDownItems

'Now use instr to check if the searching list item is there in the list
ListItemToValidate = "Four"

If Instr(DropDownItems,";" & ListItemToValidate & ";")>0 Then
  Msgbox "here goes your pass result"
Else
  Msgbox "here goes your fail result"
End If
Let me know if you have any questions.


RE: How To Find Dropdown Object based on Values from the dropdown list - sandy2404 - 12-19-2017

Hi,

I have similar issue in selecting a value from the web list. I have only 2 values in which 1st value is a default and I need to select  second value.

Example source code:

<SELECT id=D_Message.SETLCYCLE_NB class=field style="WIDTH: 60px; POSITION: absolute; LEFT: 120px; TOP: 92px" name=D_Message.SETLCYCLE_NB>
<OPTION id=DefaultValue selected value=1>1</OPTION>
<OPTION id=DefaultValue value=2>2</OPTION>
</select>

My Script:


allitems=Browser("..").Page("..").Frame("..").WebList("..").GetROProperty("all items")
    
    For i = 1 To allitems-1        

             Browser("..").Page("..").Frame("..").WebList("..").Select "2"
Next
        
But still I am not able to select second value from the weblist. Please let me know if I am missing any steps.

Regards,
Sandy