Hi.
I hope somebody will want to help me.
I saw similar topics , but they didn't help me..so i am a little bit confuse.
I need to select multiple checkboxes in a table, based on text value in a next column.
like on screenshot,..I need to select all checkboxes for elements with a name Seleniumsample.
For this checkbox i have a this location /dom[@domain='local.elabjournal.com']//table[#'table_sample']/tbody//span[@innertext=$varSampleName]/parent::td/preceding-sibling::td//input[@type='checkbox']
varSampleName - is my specific value on what I base my selection.
Ranorex can see it and in a spy he can count how many items exist now
So i need to write a code that will find all checkboxes that match to my selection .
Thanks!))
Select multiple checkboxes
-
- Posts: 36
- Joined: Mon Apr 01, 2019 12:12 pm
Select multiple checkboxes
You do not have the required permissions to view the files attached to this post.
Re: Select multiple checkboxes
Hi,
The problem is, that the SELENIUMSAMPLE text in your table is stored with uppercase! So you must fill the variable with string using the same case! Or you must enclose the variable in case 'insensitive' regex, like this:
https://www.ranorex.com/help/latest/han ... oryelement
BTW, instead of referencing repo element directly in code, use method's parameter (RepoItemInfo) to pass the repo element to method.
The problem is, that the SELENIUMSAMPLE text in your table is stored with uppercase! So you must fill the variable with string using the same case! Or you must enclose the variable in case 'insensitive' regex, like this:
Then you can use code like this, to click each check box:/dom[@domain='local.elabjournal.com']//table[#'table_sample']/tbody//span[@innertext~'^(?i:'+$varSampleName+')']/parent::td/preceding-sibling::td//input[@type='checkbox']
https://www.ranorex.com/help/latest/han ... oryelement
BTW, instead of referencing repo element directly in code, use method's parameter (RepoItemInfo) to pass the repo element to method.
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
-
- Posts: 36
- Joined: Mon Apr 01, 2019 12:12 pm
Re: Select multiple checkboxes
No) the problem is that i don't know how to ask Ranorex to select more than 1 item based on my condition.
I can store my text in lower case..this is not my issue.
i need an example of code which will select all existing elements, which match my conditions.
Thanks
I can store my text in lower case..this is not my issue.
i need an example of code which will select all existing elements, which match my conditions.
Thanks
Re: Select multiple checkboxes
Hi,
What exactly do you mean by "code which will select all existing elements"?
The xpath I provided you, lists all checkboxes, which belongs to span with inner text containing 'SELENIUMSAMPLE'... If you now want to click (check) every single checkbox from the list of available checkboxes, you must use the sample code I directed you to. You just have to replace the repo element from the sample code, with repo element, using the above xpath. And then right after line...
you should add...
method. You can, of course, replace 'button' and 'buttonList' with whatever you want. Hope this helps?
What exactly do you mean by "code which will select all existing elements"?
The xpath I provided you, lists all checkboxes, which belongs to span with inner text containing 'SELENIUMSAMPLE'... If you now want to click (check) every single checkbox from the list of available checkboxes, you must use the sample code I directed you to. You just have to replace the repo element from the sample code, with repo element, using the above xpath. And then right after line...
Code: Select all
button.MoveTo();
Code: Select all
button.Click();
You do not have the required permissions to view the files attached to this post.
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
-
- Posts: 36
- Joined: Mon Apr 01, 2019 12:12 pm
Re: Select multiple checkboxes
Thanks for help!
It took me a lot of time and nervous but i made it work.
This my code using CreateAdapters method , for first create a list with items , which match my condition.
And then to set attribute value checked to True (instead of clicking) .
Maybe it will also help somebody
It took me a lot of time and nervous but i made it work.
This my code using CreateAdapters method , for first create a list with items , which match my condition.
And then to set attribute value checked to True (instead of clicking) .
Code: Select all
private void SelectMultipleCheckboxes()
{
// Create a list of adapters using the "Info" object
IList<Ranorex.InputTag> inputList =
repo.ELABJournal.Inventory_Screen.Sample_List_Screen.Checkbox_for__Created_ItemsInfo.CreateAdapters<Ranorex.InputTag>();
System.Diagnostics.Debug.WriteLine(inputList.Count);
foreach (Ranorex.InputTag input in inputList )
{
System.Diagnostics.Debug.WriteLine(input);
Report.Info("List: "+input);
input.Checked="true";
}
}
Re: Select multiple checkboxes
Hi,
Just one more thing. I would suggest to replace this part of code...
with this...
Basically, you should avoid using repo items directly in code, like you did it, and rather reference them via method parameters. Then in recording, in which are you planning to use such method, link the repo element to given parameter. It's way better approach than hardcoding repo elements in code!
Just one more thing. I would suggest to replace this part of code...
Code: Select all
private void SelectMultipleCheckboxes()
{
// Create a list of adapters using the "Info" object
IList<Ranorex.InputTag> inputList = repo.ELABJournal.Inventory_Screen.Sample_List_Screen.Checkbox_for__Created_ItemsInfo.CreateAdapters<Ranorex.InputTag>();
with this...
Code: Select all
private void SelectMultipleCheckboxes(RepoItemInfo repoElement)
{
// Create a list of adapters using the "Info" object
IList<Ranorex.InputTag> inputList = repoElement.CreateAdapters<Ranorex.InputTag>();
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
-
- Posts: 36
- Joined: Mon Apr 01, 2019 12:12 pm
Re: Select multiple checkboxes
Okay.... i did it, it looks more nice..and works..But
Now for mu Count function he returns always a dubbel number.
if i have 7 elenemnts he will count 14
if only one - he will count 2
and i have no idea why
If i check via SPY he shows correct number of elements. Just put then in a list dubble....
What did i do wrong?))))
Thanks
Screen
https://monosnap.com/direct/sIboPhXx0HB ... J1nhf05Jlb
Code: Select all
public void SelectMultipleInput(RepoItemInfo repoElement)
{
//RepoItemInfo repoElement = repo.ELABJournal.Inventory_Screen.Sample_List_Screen.Checkbox_for__Created_ItemsInfo;
// Create a list of adapters using the "Info" object
IList<Ranorex.InputTag> inputList =
repoElement.CreateAdapters<Ranorex.InputTag>();
Report.Info("Qauntity of Samples: "+inputList.Count);
//System.Diagnostics.Debug.WriteLine(inputList.Count);
foreach (Ranorex.InputTag input in inputList )
{
input.Checked="true";
}
}
Re: Select multiple checkboxes
Hi,
Unfortunately, this problem is caused by Ranorex 9.0 bug. But the good news is that Ranorex folks managed to find the root cause of the problem and it should be fixed in very soon to be released 9.0.1Lyuba Boerma wrote: ↑Tue Apr 02, 2019 10:59 amNow for mu Count function he returns always a dubbel number.
if i have 7 elenemnts he will count 14
if only one - he will count 2
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
-
- Posts: 36
- Joined: Mon Apr 01, 2019 12:12 pm
Re: Select multiple checkboxes
aaaahhhh)
okay, understood!
it is funny that when i was using first hardcode version - it was counting correct!)
but if i make it in a nice way - it created an issue ))
But , one more time, Thank you for help!
okay, understood!
it is funny that when i was using first hardcode version - it was counting correct!)
but if i make it in a nice way - it created an issue ))
But , one more time, Thank you for help!