Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected Item of combobox enable = "false" #190

Closed
superbigsoft opened this issue Jan 6, 2014 · 8 comments
Closed

Selected Item of combobox enable = "false" #190

superbigsoft opened this issue Jan 6, 2014 · 8 comments

Comments

@superbigsoft
Copy link

Hi White team,

I have a small problem with controls have enable = "False"

For example, I have a wpf combo box define as:

<ComboBox Grid.Row="3" Grid.Column="1" x:Name="Gemeinde" DisplayMemberPath="Name" IsEnabled="False"/>

And I use white to get the selected value of this combobox

public ComboBox CbxGemeinde {
        get {
            if (m_cbxGemeinde == null) {
                m_cbxGemeinde = GetCombobox("Gemeinde");
            }
            return m_cbxGemeinde;
        }
    }
protected ComboBox GetCombobox(string controlId) {
        return Screen.Get(SearchCriteria.ByAutomationId(controlId)) as ComboBox;
    }

But the value get from combobox are:
combobox.SelectedItem is null,
combobox.Items is empty,
combobox.SelectedItemText = ""

Could you please help me check what wrong in getting selected value of combo box?

Thanks,
Nam

@JakeGinnivan
Copy link
Member

This is a limitation of the underlying UIA framework white uses.

You should use IsReadOnly=”True” rather than IsEnabled=”False”

From: superbigsoft [mailto:notifications@github.com]
Sent: 06 January 2014 09:06
To: TestStack/White
Subject: [White] Selected Item of combobox enable = "false" (#190)

Hi White team,

I have a small problem with controls have enable = "False"

For example, I have a wpf combo box define as:

And I use white to get the selected value of this combobox

public ComboBox CbxGemeinde {

    get {

        if (m_cbxGemeinde == null) {

            m_cbxGemeinde = GetCombobox("Gemeinde");

        }

        return m_cbxGemeinde;

    }

}

protected ComboBox GetCombobox(string controlId) {

    return Screen.Get(SearchCriteria.ByAutomationId(controlId)) as ComboBox;

}

But the value get from combobox are:
combobox.SelectedItem is null,
combobox.Items is empty,
combobox.SelectedItemText = ""

Could you please help me check what wrong in getting selected value of combo box?

Thanks,
Nam


Reply to this email directly or view it on GitHubhttps://github.com//issues/190.

@superbigsoft
Copy link
Author

Thanks for your fast answer!

Is there any work-around for this? We need this feature to validate the SelectedItem in the Combobox.

Thanks,
Nam

@JakeGinnivan
Copy link
Member

Unfortunately not. The only workaround is to make the combobox readonly instead of disabled.

@JakeGinnivan
Copy link
Member

Closing issue, this is not possible from UIA.

@superbigsoft maybe try the COMUIA Branch, you can get the NuGet packages from my build server. It uses the newer COM libraries and MAY support it. But no guarantees. Try using inspect.exe and see if it can see the information you need, if it can, then the Com UIA branch may work for you

@ponprabhu
Copy link

Hi Team,
I am currently facing the same issue. When combobox is disabled i can't get the items inside it.
Is this issue fixed?

Thanks

@ponprabhu
Copy link

I have used another technique to get the selected item from the disabled dropdownlist.
Thanks.

@JakeGinnivan
Copy link
Member

Would you be able to post your findings to help others?

@ponprabhu
Copy link

For My scenario, I have to take a selected item text from the disabled combobox. So I have just assigned the combobox automation element into textbox and take a value from the textbox like below.

var groupChild = _contentOwnerGroupElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Group));
var comboElement = groupChild.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ComboBox));
ownerText = new TextBox(comboElement, AppContext.ActionListener);
var selectedValue = ownerText.Text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants