Hello Team
I am new to Ranorex and need some help with If statements during recording session.
I land on a page, If the Checkbox is unchecked, I would like Ranorex to check it and move onto the next one
likewise if we arrive on the page and the Checkbox is already checked, I would like it to ignore and move onto the next checkbox and likewise continue.
Any help will be apprecaited.
Hammad
If Statements
Re: If Statements
Hi Hammad and welcome here,
There is currently no way to perform conditional statements within Recorded steps. The only way to achieve what you want is to use User Action or Code Module.
What you can do is to convert the recorded "check" step to user code, then add "If" statement (evaluating the actual state of checkbox) and do whatever you want with it based of its state.
There are many posts discussing evaluation of checkboxs via code. Try for example these...
http://www.ranorex.com/forum/how-to-che ... t6087.html
http://www.ranorex.com/forum/validate-s ... t7256.html
There is currently no way to perform conditional statements within Recorded steps. The only way to achieve what you want is to use User Action or Code Module.
What you can do is to convert the recorded "check" step to user code, then add "If" statement (evaluating the actual state of checkbox) and do whatever you want with it based of its state.
There are many posts discussing evaluation of checkboxs via code. Try for example these...
http://www.ranorex.com/forum/how-to-che ... t6087.html
http://www.ranorex.com/forum/validate-s ... t7256.html
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
-
- Certified Professional
- Posts: 74
- Joined: Mon Aug 14, 2006 7:17 pm
- Location: CH
Re: If Statements
Hi Hammad,
we are handling Radiobutton, Checkboxes with the following approach.
We pass a boolean, if the checkbox has to be selected or not. That means if you want that checkbox is selected you pass true. So if your checkbox is already set, then noting happens otherwise the checkbox will be selected.
We have implemented method like this (simplified):
Regards
Dan
we are handling Radiobutton, Checkboxes with the following approach.
We pass a boolean, if the checkbox has to be selected or not. That means if you want that checkbox is selected you pass true. So if your checkbox is already set, then noting happens otherwise the checkbox will be selected.
We have implemented method like this (simplified):
private void ClickToggleWebElement(RepoItemInfo repoInfo, bool selected) { Unknown unknown = base.CreateUnknown(repoInfo); InputTag inputTag = unknown.Element; if (!selected && bool.Parse(inputTag.Checked)) { inputTag.Checked = "false"; } // add your own code }I hope this helps.
Regards
Dan