Skip to content

After trying select value in a Combobox that have already selected, Combobox remains expanded. #168

Closed

Description

@elbit61

Hello, there
I met a problem in a Select method for a combobox: after try to select value that have already selected, combo box remains in expanded state.

This is help me:

public static void SelectItemAndClose(this ComboBox target, string itemText)
{
target.Select(itemText);
CollapseComboBox(target);
}

public static void SelectItemAndClose(this ComboBox target, int index)
{
target.Select(index);
CollapseComboBox(target);
}

private static void CollapseComboBox(ComboBox target)
{
var ecp = target.AutomationElement.GetPattern(ExpandCollapsePattern.Pattern);
if (ecp != null && ecp.Current.ExpandCollapseState == ExpandCollapseState.Expanded)
{
ecp.Collapse();
}
}

Thanks.

Activity

  1. ilia-murzinov commented on Jan 7, 2014

    @ilia-murzinov
    Contributor

    Confirmed, looking into it.

  2. ilia-murzinov commented on Jan 7, 2014

    @ilia-murzinov
    Contributor

    Pull request #196.

  3. rvipandey commented on Feb 21, 2017

    @rvipandey

    i did not able to find GetPattern method in

        private static void CollapseComboBox(TestStack.White.UIItems.ListBoxItems.ComboBox target)
        {
            var ecp = target.AutomationElement.GetPattern
        }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions