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

How to get property like LegacyIAccessible.State: or Toggle.ToggleState: of CheckBox control #198

Closed
Manvibha opened this issue Jun 6, 2017 · 4 comments

Comments

@Manvibha
Copy link

Manvibha commented Jun 6, 2017

Hi,

I am working a POC with WPF application and trying to properties of checkbox control to check checkbox is checked or not and take a required action further. below is code where I am trying to other property of checkbox at runtime.
WindowsElement cellObj = session.FindElementByAccessibilityId("Checkbox");
if (cellObj.GetAttribute("Toggle.ToggleState:").Contains("Off"))
{
cellObj.Click();
}
In the above code , trying to get a attribute Toggle state or LegacyIAccessible.State: and see what is the state of checkbox. But this returns NULL all the time and for other attribute of checkbox as well.
Is there something that I am doing wrong . Any suggestion welcome. :)
Or
Is This something WinAppDriver lacks as of now and any enhancements in next release?

regards,
Mahi

@timotiusmargo
Copy link
Contributor

Hi @Manvibha,

Can you please try the same approach that checkbox in UWP app is being tested below?
https://github.com/Microsoft/WinAppDriver/blob/master/Tests/UWPControls/CheckBox.cs#L104

In UWP app a CheckBox UI control Selected property returns true when it is checked and false otherwise. E.g.

var originalState = checkBoxElement1.Selected;
checkBoxElement1.Click(); // Toggling the state
Assert.AreNotEqual(originalState, checkBoxElement1.Selected);
checkBoxElement1.Click(); // Toggling the state
Assert.AreEqual(originalState, checkBoxElement1.Selected);

@Manvibha
Copy link
Author

Manvibha commented Jun 8, 2017

Thanks A lot Timotiusmargo.
It worked the way I wanted!!!

Regards,
Mahi

@Manvibha Manvibha closed this as completed Jun 8, 2017
@coolyouni
Copy link

I want to know the disable checkbox is checked or not but i am not getting the value either it is checked or not. i have used (LegacyIAccessible.State:) and Toggle.ToggleState it is showing always false what is the reason? my checkbox is actually disabled and we cannot checked or unchecked.
issue1

@liljohnak
Copy link

Consider making a method like:

private void ToggleCheckbox(AppiumWebElement checkbox, bool checked)
{
if(checkbox.Selected.Equals(checked)) return;
checkbox.Selected = checked;
}

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

4 participants