Hi Team,
I am working on windows based application where I want to click on checkboxlistitem, I am able to click on listitem as attached in snpashot.
I am trying with below code.
Ranorex.List casList= labWinRepo.EfterbestaellningAnalyser.EditPnl.CLBlocknr;IList<ListItem> listOfChkBox=casList.FindChildren<ListItem>();
int cnt = listOfChkBox.Count;
foreach(Ranorex.ListItem chkBox in listOfChkBox)
{
chkBox.Focus();
Mouse.Click(chkBox);
}
}
Unable to check the checkboxlistitem
Unable to check the checkboxlistitem
You do not have the required permissions to view the files attached to this post.
Re: Unable to check the checkboxlistitem
Hi,
You don't have to use FindChildren at all and I would personally avoid hardcoding repo item in code. I would suggest to create a method, with RepoItemInfo parameter, pointing to repo element returning list of all ListItems, with xpath like this:
Then use this code, which should create a list of all list items and click them:
Hope this helps?
You don't have to use FindChildren at all and I would personally avoid hardcoding repo item in code. I would suggest to create a method, with RepoItemInfo parameter, pointing to repo element returning list of all ListItems, with xpath like this:
Code: Select all
/form[@name='SyLaEfterbestFrm']/container[@name='editPnl']//list[@name='CLBlocknr']/listitem
Code: Select all
public void ClickListItems(RepoItemInfo listItemsInfo) // where listItemsInfo points to the repo element, with xpath returning list of all listitems
{
IList <Ranorex.ListItem> listItemsList = listItemsInfo.CreateAdapters<Ranorex.ListItem>(false);
foreach (Ranorex.ListItem listItemSingle in listItemsList )
{
listItemSingle.Click();
}
}
Last edited by odklizec on Mon May 27, 2019 11:09 am, edited 1 time in total.
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: Unable to check the checkboxlistitem
Hi ,
I tried with below code but getting error.
Cannot implicitly convert type 'Ranorex.ListItem' to 'System.Collections.Generic.IList<Ranorex.ListItem>'. An explicit conversion exists (are you missing a cast?)
I tried with below code but getting error.
Cannot implicitly convert type 'Ranorex.ListItem' to 'System.Collections.Generic.IList<Ranorex.ListItem>'. An explicit conversion exists (are you missing a cast?)
Re: Unable to check the checkboxlistitem
Hi,
Sorry, my mistake. Please try to change listItemsInfo.CreateAdapter to listItemsInfo.CreateAdapters.
Sorry, my mistake. Please try to change listItemsInfo.CreateAdapter to listItemsInfo.CreateAdapters.
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: Unable to check the checkboxlistitem
Hi ,
As attached in snapshot, In this List 'CLBlocknr' hierarchy I am trying to click on /listitem[@name='/A/1 - abc'] but if you see the advance settings Under Dynamic Checked is false , but when I manually change it to true .. listitem[@name='/A/1 - abc' is checked .. but with the below code I am not able to click on checkbox but able to click on string of listItem. Please suggest.
As attached in snapshot, In this List 'CLBlocknr' hierarchy I am trying to click on /listitem[@name='/A/1 - abc'] but if you see the advance settings Under Dynamic Checked is false , but when I manually change it to true .. listitem[@name='/A/1 - abc' is checked .. but with the below code I am not able to click on checkbox but able to click on string of listItem. Please suggest.
You do not have the required permissions to view the files attached to this post.
Re: Unable to check the checkboxlistitem
Hi,
Well, the snapshot does not differ between the checkbox square and its description. Which means, there is no way to track and click just the checkbox element. I guess that if you manually click (simple left click) the checkbox name, it will not check the checkbox square as well? In this case, try double click action. Depending of the checkbox implementation, double click could help.
Another way could be to click on string, just to select the item you want to check, and then send 'Space' shortcut, which should check the checkbox. And yet another solution could be using SetValue (Checked) or InvokeAction (Check/Uncheck or DoDefaultAction) actions.
Well, the snapshot does not differ between the checkbox square and its description. Which means, there is no way to track and click just the checkbox element. I guess that if you manually click (simple left click) the checkbox name, it will not check the checkbox square as well? In this case, try double click action. Depending of the checkbox implementation, double click could help.
Another way could be to click on string, just to select the item you want to check, and then send 'Space' shortcut, which should check the checkbox. And yet another solution could be using SetValue (Checked) or InvokeAction (Check/Uncheck or DoDefaultAction) actions.
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: Unable to check the checkboxlistitem
Thanks ,
Spacebar solution worked!!
Spacebar solution worked!!