Forum Discussion

googleid_105206's avatar
googleid_105206
Contributor
13 years ago

How to select specfic PopupMenuButton using testcomplete on Flex Application

Hi

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

I am facing issue while selecting specific button  from PopupMenuButton


To identify flex objects i am using Flash Injector method.

 i using find child method to identify object.How can select specific PopupMenuButton  by passing parameter.

Sub Test3

  Dim page

  Dim vobject

  Set page = Aliases.firefox.pageHttp1721661658080

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

  Set vobject = page.objectSample

  vobject.objectSample.scrollerScroller7.navigatorcontentAssets.dividedboxHdividedbox289.skinnablecontainerSkinnableconta.popupmenubuttonPopupmenubutton26.ClickButton

  vobject.menucontrol0.menuitemrendererSelectAll.ClickButton

End Sub






Thanks,

Vijay

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Vijay,



    First of all, please note that currently TestComplete 8.6 does not support Flex 4.6. It supports only Flex 3.3-4.5, so we cannot guarantee 100% compatibility with Flex 4.6 apps.



    Back to your question. To identify an object using the FindChild method, you need to specify unique property values that can be used for object identification.



    In the Object Spy, you can see that popup menu items are represented as MenuItemRenderer objects. By exploring object properties, you can find out that the menu item text is specified by the FlexObject.listData.label property. So, to identify a menu item by text using the FindChild method, you can search for an object whose ObjectType is MenuItemRenderer and FlexObject.listData.label is equal to the desired text.



    Note also that PopUpMenuButton's drop-down list is not a child object of PopUpMenuButton, but a child object of the Flex application (the vobject) object in your script. So you'll need to apply the FindChild method to the Flex application object.



    If we put everything together, the code for clicking PopUpMenuButton and selecting an item from the pop-up menu would look like this:



    Sub Test3

      Dim page, vobject, button



      Set page = Aliases.firefox.pageHttp1721661658080

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

      Set vobject = page.objectSample

      Set button = vobject.objectSample.scrollerScroller7.navigatorcontentAssets.dividedboxHdividedbox289.skinnablecontainerSkinnableconta.popupmenubuttonPopupmenubutton26



      Call ClickPopUpMenuItem(button, "Item Text")

    End Sub





    Sub ClickPopUpMenuItem(PopUpMenuButton, ItemText)

      Call PopUpMenuButton.Click(PopUpMenuButton.Width-5, PopUpMenuButtonHeight/2)



      Dim AppObject, ItemObject, PropNames, PropValues



      ' Obtain the Flex application object

      Set AppObject = PopUpMenuButton.Parent

      Do Until AppObject.ObjectType = "Object"

        Set AppObject = AppObject.Parent

      Loop



      ' Find a pop-up menu item by text

      PropNames = Array("ObjectType", "FlexObject.listData.label")

      PropValues = Array("MenuItemRenderer", ItemText)

      Set ItemObject = AppObject.FindChild(PropNames, PropValues, 5)



      If ItemObject.Exists Then

        ItemObject.Click

      Else

        Call Log.Error("PopUpMenuButton item """ & ItemText & """ was not found.")

      End If

    End Sub


    Try it out and see how it works for you.
  • Hi

    Helen Kosova,



     It's working fine.i can able to select specific popup menu buttons.





    Thank u,

    Vijayabhaskar