This is a migrated thread and some comments may be shown as answers.

How to select checkboxes randomly

3 Answers 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peiyuan
Top achievements
Rank 1
Peiyuan asked on 22 Dec 2015, 07:43 PM

Hello,

 I have a list of checkboxes. Do you know how to select checkboxes randomly from the list?

 If I selected a checkbox by simply recording it, the code would use HtmlInputCheckBox to do the operation like clicking. 

 My original thought is using random checkbox id so that I can selected checkbox randomly. When I use Find.ById() to locate a check box element, the return type is element which does not have method like clicking.

 Hope you guys can help me with this. Thanks!

 Peiyuan

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 23 Dec 2015, 07:51 PM
Hello Peiyuan,

You can search for an HTML input checkbox and cast it properly like this:
HtmlInputCheckBox chkBox = ActiveBrowser.Find.ById<HtmlInputCheckBox>("my random id here");

My question to you is how are you going to generate a random ID to search for?


Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Peiyuan
Top achievements
Rank 1
answered on 23 Dec 2015, 07:57 PM

Hello Cody,

 Thanks for answering! I will try your solution right now.

The checkbox ID in my test page is following a rule. I can generate a random checkbox ID by the rule.

Thanks,

Peiyuan

0
Cody
Telerik team
answered on 23 Dec 2015, 08:41 PM
Hello,

Okay sounds good. Let us know if you need any further assistance.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Peiyuan
Top achievements
Rank 1
Answers by
Cody
Telerik team
Peiyuan
Top achievements
Rank 1
Share this question
or