Uncheck multiple CB
Uncheck multiple CB
Hello I have a question. I have a list of 16 checkboxes and I need only 1 of them selected and the rest unchecked, ranorex must check that the selected cb is checked and that the rest is unchecked and if one of them is also checked then uncheck it
Re: Uncheck multiple CB
Hi,
Please upload a Ranorex snapshot (NOT screenshot) of the UI in question (with all checkboxes). Without, at very least, snapshot it's hard to suggest something reliable.
Generally speaking, you must create a repo item with xpath, which returns all checboexs. Then you need to create a list of items, using code as described here:
https://www.ranorex.com/help/latest/han ... oryelement
Using the above code (of course modified), you can get the state of each checkbox and eventually uncheck it if checked.
Please upload a Ranorex snapshot (NOT screenshot) of the UI in question (with all checkboxes). Without, at very least, snapshot it's hard to suggest something reliable.
Generally speaking, you must create a repo item with xpath, which returns all checboexs. Then you need to create a list of items, using code as described here:
https://www.ranorex.com/help/latest/han ... oryelement
Using the above code (of course modified), you can get the state of each checkbox and eventually uncheck it if checked.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Uncheck multiple CB
Attached I am sending a snap
You do not have the required permissions to view the files attached to this post.
Re: Uncheck multiple CB
I need to Check or uncheck only first CB column
Re: Uncheck multiple CB
Hi,
Thanks for the snapshot. So, basically, you need to create a repo element with xpath like this:
This will return all checkboxes from left column.
Now you need to pass the repo element to UserCode like this:I've not tested the code, so it may need some refinements? But generally, it should give you an idea what to do
Thanks for the snapshot. So, basically, you need to create a repo element with xpath like this:
Code: Select all
/form[@name='PraDialog']//checkbox[@instance='0']
Now you need to pass the repo element to UserCode like this:
Code: Select all
private void UncheckAllChecked(RepoItemInfo repoElement)
{
IList<Ranorex.CheckBox> checkBoxList= listItemsInfo.CreateAdapters<Ranorex.CheckBox>();
foreach (Ranorex.CheckBox chekBoxItem in checkBoxList)
{
if (chekBoxItem.Element.GetAttributeValue<bool>("Checked"))
{
Report.Info("CheckBox Item: " + chekBoxItem.Find<Ranorex.Text>("./preceding-sibling::text").Element.GetAttributeValueText("Text").ToString()); //this should return name of check box
chekBoxItem.Click();
}
}
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Uncheck multiple CB
I write something like this
I had no idea or knowledge of how to do it with code
generally works
IList<Ranorex.CheckBox> TCheckBoxList = repo.PraDialog.TCheckBoxInfo.CreateAdapters<Ranorex.CheckBox>(); foreach (Ranorex.CheckBox TCheckBox in TCheckBoxList) { if(TCheckBox.Checked) { TCheckBox.Click(); } }this code uncheck all CB and then I have a recording where I click on the nr of CB from variable
I had no idea or knowledge of how to do it with code
generally works