How to select checkboxes randomly

4 posts, 0 answers
  1. Peiyuan
    Peiyuan avatar
    6 posts
    Member since:
    Nov 2015

    Posted 22 Dec 2015 Link to this post

    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

  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Dec 2015 Link to this post

    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!
  3. Peiyuan
    Peiyuan avatar
    6 posts
    Member since:
    Nov 2015

    Posted 23 Dec 2015 Link to this post

    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

  4. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 23 Dec 2015 Link to this post

    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!
Back to Top