Forum Discussion

Know's avatar
Know
New Contributor
5 days ago

Unable to select value from dropdown list with popop render out of Object Tree

Hi, I'm encountering the issue: unable to select the value from dropdown list

the value from dropdown list has object: Aliases.FramingStylesEditor.WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WPFObject("GroupItem", "", 2).WPFObject("ComboBoxItem", "", 2).WPFObject("TextBlock", "OSB 7/16", 1)

Although the dropdown list has expanded, but it still not clicked

6 Replies

  • This issue, where you've expanded the dropdown but are unable to select the value using the specified WPF object path, often occurs because the final TextBlock object representing the value ("OSB 7/16") is a static display element and not the interactive element (like a ComboBoxItem or MenuItem) that handles the click event to perform the selection. To successfully select the value, you should target the e-zpassin com parent interactive object, which in your case appears to be the WPFObject("ComboBoxItem", "", 2) that contains the text. Try modifying your selection command to target this ComboBoxItem instead of drilling down to the TextBlock, as this parent object is typically configured to handle the click action for item selection in WPF controls.

    • Know's avatar
      Know
      New Contributor

      I've also tried target to ComboBoxItem object but it still not work

      Aliases.FramingStylesEditor.Popup.PopupRoot.Decorator.NonLogicalAdornerDecorator.GroupItem.ComboBoxItem

      Here is the object that I target. 

      Aliases.FramingStylesEditor.WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WPFObject("GroupItem", "", 2).WPFObject("ComboBoxItem", "", 2)

      Even though the dropdown list is expanded, the value still cannot be selected and it doesn't throw any error either.

      • Hassan_Ballan's avatar
        Hassan_Ballan
        Icon for Champion Level 3 rankChampion Level 3

        My question may be silly but I thought to ask it. Have you tried recording? 

        In a new project, to test, I would record such action and see if it plays back and what code TestComplete did.

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    The code that you have provided only shows the name mapping, but you're not performing any action. You should be either calling the method Click() or ClickItem("ItemX"). For example,

    Aliases.FramingStylesEditor.WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WPFObject("GroupItem", "", 2).WPFObject("ComboBoxItem", "", 2).WPFObject("TextBlock", "OSB 7/16", 1).Click();

    or, if "OSB 7/16" is the item that you want to select, then it's

    Aliases.FramingStylesEditor.WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WPFObject("GroupItem", "", 2).WPFObject("ComboBoxItem", "", 2).ClickItem("OSB 7/16");

     

     

    • Know's avatar
      Know
      New Contributor

      Hi, 

      I've add step to perform action, but it still doesn't work

      - Below is the code:

      function cboSelectWPF(inventoryType, value)
      {   
        switch (inventoryType) {
          case DEFAULT_BEAM:     combobox = ddDefaultBeam ; break;
          case DEFAULT_SHEET:    combobox = ddDefaultSheet ; break;
          case BOTTOM_PLATE:     combobox = ddBottomPlate ; break;
          case SPACING_BEAMS:    combobox = ddSpacingBeams ; break;
          case TOP_PLATE:        combobox = ddTopPlate ; break;
        }
        combobox.ClickItem(value);
      }

      combobox is dropdown list with object in the screenshot

      - Here is the properties of dropdown object. Could you pls check?

       

      --------------------

      Also I tried another way by expanding the dropdown menu then selecting a value but it didn't work.

      I see the drop down menu expanded but can't select a value.

      here is the script that I used to expanded the dropdown, then select the value with Click() function


      function cboSelectWPF(inventoryType)
      {   
        switch (inventoryType) {
          case DEFAULT_BEAM:     combobox = ddDefaultBeam ; break;
          case DEFAULT_SHEET:    combobox = ddDefaultSheet ; break;
          case BOTTOM_PLATE:     combobox = ddBottomPlate ; break;
          case SPACING_BEAMS:    combobox = ddSpacingBeams ; break;
          case TOP_PLATE:        combobox = ddTopPlate ; break;
        }
        combobox.Click();
        aqUtils.Delay(1000);
        tb2x4.Click();
        }

        combobox.Click(): to expand the dropdown list

        tb2x4.Click(): select with the value 2x4 from dropdown list

       

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        First - get the name mapping of this control,

        Use either full name or alias name mapping for this control.

        Second - then perform object.ClickItem("2 X 4") to select the desired item shown in the list,

        ClickItem("2 X 4")

        Where object is the name mapping of the control, and assuming "2 X 4" is the item to be selected. Note the list of items shown, might be a custom control, as combo control usually just has list of items. But in this instance, it's showing labels as well i.e. "Lumber Inventory" and "Sheet Inventory".

        I suggest you try the example code, that I had originally provided (not using cboSelectWPF), to check the functionality of ClickItem() actually works for you. Also, since this is a WPF object, there may be a method that you can use, shown in the Methods tab.

        FYI. Your alias name is way to long - refer to Name Mapping