Setting checkboxes to specific values

Class library usage, coding and language questions.
User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Setting checkboxes to specific values

Post by Ciege » Fri Feb 10, 2012 5:52 pm

omayer wrote:Hi Ciege,
if page contains 10 different checkboxes and all 10 checkboxes has diff control name, so when i call the function clickcheck w/passing controlname as parameter, how does it work ...shouldn't i have to create 10 different functions to get the object name then passing to the caller, any input please.
Beginner
Just pass the proper parameters to the method and the method finds the proper checkbox.

Code: Select all

public static int CheckBoxClick(Boolean SelectCheckBox, Ranorex.Form RanorexFormName, String CheckBoxName)
SelectCheckBox - pass true or false depending on if you want to check or uncheck the checkbox.
RanorexFormName - pass the Ranorex.Form element that your checkbox lives on. The method will search this form for the checkbox.
CheckBoxName - pass the controlname or text of the checkbox. The method will search for the element with this controlname or text.

So in your case, you have 10 different checkboxes on the same form. Assume you want to set them all to true and assume you are searching the same form for each. Just call the method 10 times with the different controlname of the checkbox.
I.e.

Code: Select all

intResult = CheckBoxClick(True, MyForm, "CheckBox1")
intResult = CheckBoxClick(True, MyForm, "CheckBox2")
intResult = CheckBoxClick(True, MyForm, "CheckBox3")
etc...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: Setting checkboxes to specific values

Post by omayer » Fri Feb 10, 2012 6:45 pm

thank you Ciege to explained in great details, it was also my understanding "Just call the method 10 times with the different controlname of the checkbox." that means to get the controlname "CheckBox1"..I have to create 10 different functions.
thanks,
beginner
Tipu

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Setting checkboxes to specific values

Post by Ciege » Fri Feb 10, 2012 6:49 pm

Not really... If you know the text name of the checkbox as it is displayed oin the screen you can just pass that...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...