Forum Discussion

googleid_105206's avatar
googleid_105206
Contributor
15 years ago

How to select specfic List item from dropdown and Comobox

Hi

I am Working on Flex4.6 based application using testcomplete 8.6

I am facing issue while selecting  specfic List item from dropdown box and Comobox .

To identify flex objects i am using Flash Injector method.

 by using find child method to identify object.How can i select specific DropDown list by passing parameter. unable get dropdown object propertys and propertys  values. how can i Select dropdown and comobox list items.

Sub Test3

  Dim page

  Dim vobject

  Set page = Aliases.firefox.pageHttp1721661658080

  Call page.ToUrl("http://172.16.6.165:8080/")

 

Set navigatorContent = scroller.navigatorcontentAssets.dividedboxHdividedbox272.dividedboxVdividedbox273.navigatorcontentNavigatorcontent

Call navigatorContent.dropdownlistDropdownlist429.Click(74, 9)



Call vobject.group0.scrollerScroller871.listitemDefaultitemrenderer901.Click(60, 12)


Call navigatorContent.bordercontainerBordercontainer43.comboboxListsearchfields.ClickItem("REFID")


End Sub


Thanks,

Vijay

21 Replies

  • Hi Helen,





    Now problem was resolved and  it's  speed up the test actions.how do i know depth of  child (Find Child ) object.









    Regards,

    Vijay








  • Hi Vijay,



    how do i know depth of child (Find Child ) object.


    You can capture the target object with the Object Spy and simply count how many objects there are between this object and the one to which FindChild is applied. I've attached a screenshot for your reference.


  • Hi

    I am Working on Flex4.5 based application using testcomplete 8.6

    I am facing issue while selecting  specific List item from dropdown box .To identify flex objects i am using Flash Injector method.  i can able handle dropdown and list item also.But problem with  some of the list items are not visible,while scrolling time only we can see rest of the  list items.


    Below code is working for to click to visble list item.How can handle unvisble list items.  list items name are we passing  dynamically .


    set dropdownClick=page.FindChild("ObjectIdentifier","combo_0", 6)

     dropdownClick.Click


    set subListitemClick=page.FindChild("ObjectIdentifier","Boys", 6)

       subListitemClick.Click 


    How handle this type object .iam sending screen shots .please find the attached screen shots.

    Regards,


    Vijay



  • Hi Vijay,



    To handle an item that's currently invisible, you can call the native ensureIndexIsVisible method of the DropDownList control to scroll this item into view. Here's an example:



    set dropdownClick=page.FindChild("ObjectIdentifier","combo_0", 6)

    dropdownClick.Click



    ' Scroll the item into view

    set list = ... ' Obtain the DropDownList control

    index = ItemIndexByText(list, "Boys")

    Call list.FlexObject.ensureIndexIsVisible(index)



    set subListitemClick=page.FindChild("ObjectIdentifier","Boys", 6)

    subListitemClick.Click

    ...



    ' Returns the list item index by its text.

    ' Parameters:

    ' DropDownList - a Spark DropDownList control

    ' ItemText - the list item text

    Function ItemIndexByText(DropDownList, ItemText)

      Dim i

      For i = 0 To DropDownList.ItemCount - 1

        If DropDownList.Item(i) = ItemText Then

          ItemIndexByText = i

          Exit Function

        End If

      Next

      ItemIndexByText = -1

    End Function


    Let me know how this works for you.





    By the way, we've released an update for TestComplete with support for Flex 4.6 and Flash Player 11. So I recommend that you install the new version to take advantage of the new functionality.
  • Hi

    Helen Kosova
    ,



     Unable to get  "ItemIndexByText".Please give me some explanation  about "ItemIndexByText".how to scroll the item into view and dropdown List Control.

     Full Name of  list item :
    Sys.Process("firefox").Page("http://172.16.6/").Object("MM").Group("dropDown").Scroller("scroller").ListItem("Boys")



    Recording the Application below code generated.

      Call firefox.pageHttp172.object Mm.group0.scrollerScroller1734.listitemDefaultitemrenderer1767.Click(39, 6)

    .......

    ' Scroll the item into view

    set list = ... ' Obtain the DropDownList control

    index = ItemIndexByText(list, "Boys")



     



    Please find the  attached screen shot.Please suggest me to handle above
    objects 





    Thanks,

    Vijay




  • Hi Vijay,



    After rereading your questions, it seems to me that the problem could be the confusing object names in the generated script.



    Let me clarify. Your recorded script:
    is essentially the same as

     - that's your target item.



    If the autogenerated aliases aren't descriptive enough, you can rename them in the Name Mapping editor to more descriptive and meaningful names. For example, you can rename group0, scrollerScroller1734 and listitemDefaultitemrenderer1767 to group, scroller and ListItemBoys, respectively. After that, you can modify the recorded script in the following way:
    so that it's more clear which list item is clicked.



    If you want to directly specify the list item text in your script, you can address the list item object dynamically, like this:



    Is this what you originally meant?
  • Hi 



    Helen Kosova
    ,





    Finally i got solution.My problem was resolved .Thank you very much.







    Thanks,

    Vijay
  • bindu's avatar
    bindu
    Occasional Contributor
    Hi,

    I need to select/click on an Item in Flex Drop down. What ever i do I was not able to select the item from the drop down. Please refer to the below code.


    sub Flex_ClickDropDownListItem

    dim count, i, j

    set ObjName = aliases.iexplore.pgeBS.cmbdropdown

    vData = "ABC"

    count = ObjName.ItemCount

    for i=0 to count-1

    if ObjName.FlexObject.dataProvider.source.item(i).name = vData then

    ObjName.FlexObject.setFocus

    ObjName.ClickItem (i)

    exit for

    end
    if

    next

    End
    Sub



    In the above mentioned code, It is verifying the If condition but, does not click on the item. Test Complete Log says "Cannot activate the item.

    Please provide me a solution for this as I have to deal with many drop downs in my application.


    Flex_ClickDropDownListItem count, i, j ObjName = .iexplore.pgeBS.cmbdropdownvData = "ABC"count = ObjName.ItemCount i=0 count-1 ObjName.FlexObject.dataProvider.source.item(i).name = vData ObjName.FlexObject.setFocusObjName.ClickItem (i)  
  • Hi Bindu,



    Please follow below code  to Click specific drop-down  item.



     propNames = Array("ObjectType", "ObjectIdentifier")

      propValues = Array("DropDownList","combo_0")

      set ListObject=Context.FindChild(PropNames,PropValues, 9)

     

      ListObject.Click

       ItemText="brand"

        

      Set dataProvider=ListObject.FlexObject.dataProvider

     

        log.Message dataProvider

          log.Message dataProvider.length

      found = False

      For i = 0 To dataProvider.length

     

      If dataProvider.source.item(i).value=ItemText Then    

         ItemIndexByText = i

         log.Message ItemIndexByText

         ListObject.FlexObject.ensureIndexIsVisible(ItemIndexByText)

           

           delay 2000

           found = True

          Exit For

        End If

      Next



      If Not found Then

        Log.Error "DropDownList item """ & ItemText & """ was not found."

        'Exit Sub

      End If

         

         Set app =ListObject.Parent

      Do Until app.ObjectType ="Object"

        Set app = app.Parent

      Loop



      ' Find the list item object by text

      propNames = Array("ObjectType", "Caption")

      propValues = Array("ListItem", ItemText)

      Set item =app.FindChild(propNames, propValues, 2)



      If item.Exists Then

        item.Click

      Log.message ItemText& "Select form Drop down list"

       Else

      Log.message ItemText& "Was not Select form Drop down list"

       End If 



    Let me know how this works for you.



    Thanks,

    Vijay

    d.kavijay@gmail.com



        
  • Hi Bindu,



    if  Drop-down items(ABC) invisible follow below code.


    Sub test



    Dim ObjName, propNames, propValues


    ObjName, propNames, propValues

    propNames = Array("ObjectType", "ObjectIdentifier")   * Take Object label Property


    propValues = Array("DropDownList","DropDownList591")   * Take Object label Value


    set ListObject=ObjName.FindChild(PropNames,PropValues, 9)  * list object not Found  Increase Depth


    ListObject.Click


    ItemText="ABC" 


    Set dataProvider=ListObject.FlexObject.dataProvider 


    log.Message dataProvider


    log.Message dataProvider.length


    found = False


    For i = 0 To dataProvider.length 


    If dataProvider.source.item(i).name=ItemText Then   * Check the 'ABC ' in Data Provider (name/label) path hierarchy of ABC


    ItemIndexByText = i


    log.Message ItemIndexByText


    ListObject.FlexObject.ensureIndexIsVisible(ItemIndexByText)


    delay 2000


    found = True


    Exit For


    End If


    Next


    If Not found Then


    Log.Error "DropDownList item """ & ItemText & """ was not found."


    'Exit Sub


    End If



    Set app =ListObject.Parent

      Do Until app.ObjectType ="Object"

        Set app = app.Parent

      Loop


    ' Find the list item object by text


    propNames = Array("ObjectType", "Caption")  * Take ObjectLabel/Caption


    propValues = Array("DropDownList",ItemText)


    Set item =app.FindChild(propNames, propValues, 2) 


    If item.Exists Then


    item.Click


    Log.message ItemText& "Select form Drop down list"


    Else


    Log.message ItemText& "Was not Select form Drop down list"


    End If



    end sub


    if DropDown Item is Visible Follow below code
    .






    Sub test



    Dim ObjName, propNames, propValues


    ObjName, propNames, propValues

    propNames = Array("ObjectType", "ObjectIdentifier")   * Take Object label Property


    propValues = Array("DropDownList","DropDownList591")   * Take Object label Value


    set ListObject=ObjName.FindChild(PropNames,PropValues, 9)  * list object not Found  Increase Depth



    ItemText="ABC" 


    Set dataProvider=ListObject.FlexObject.dataProvider 


    log.Message dataProvider


    log.Message dataProvider.length


    found = False


    For i = 0 To dataProvider.length 


    If dataProvider.source.item(i).name=ItemText Then   * Check the 'ABC ' in Data Provider (name/label) path hierarchy


    ItemIndexByText = i


    log.Message ItemIndexByText



    delay 2000


    found = True


    Exit For


    End If


    Next


    If Not found Then


    Log.Error "DropDownList item """ & ItemText & """ was not found."


    'Exit Sub


    End If


    ListObject.Click



    Set app =ListObject.Parent

      Do Until app.ObjectType ="Object"

        Set app = app.Parent

      Loop






    ' Find the list item object by text


    propNames = Array("ObjectType", "Caption")  * Take ObjectLabel/Caption


    propValues = Array("DropDownList",ItemText)


    Set item =app.FindChild(propNames, propValues, 2) 


    If item.Exists Then


    item.Click


    Log.message ItemText& "Select form Drop down list"


    Else


    Log.message ItemText& "Was not Select form Drop down list"


    End If



    end sub




    Let me know how this works for you.



    Thanks,

    Vijay

    d.kavijay@gmail.com