Iterate through DOM objects

2 posts, 0 answers
  1. Ghandi
    Ghandi avatar
    5 posts
    Member since:
    Feb 2013

    Posted 16 Apr 2013 Link to this post


    I have a selection of checkboxes that are created dynamically and so the test environment can never be sure of how many there will be.

    We have Select All / Deselect All links which we already test for, but I would like to iterate through some test steps based on the current number of these checkboxes each time, however many there may be.

    So essentially:

    for each checkbox c in div-a {
         Insert test steps here, and be able to reference the current active checkbox (c) each time

    I am using the Telerik Test Studio IDE environment with very little use of custom coded steps

  2. Plamen
    Plamen avatar
    8 posts

    Posted 18 Apr 2013 Link to this post

    Hello Ghandi,

    You can put the steps you want to perform when the current active checkbox is selected in a Test as Step. You can call it CommonCheckboxSteps for example. Then you can get a collection of all checkboxes inside of the div element and execute the CommonCheckboxSteps test for each checkbox in the collection. Here's a sample code:
    foreach(HtmlInputCheckBox checkbox in myDiv.Find.AllByAttributes<HtmlInputCheckBox>("type=checkbox"))
        //Check the checkbox
        checkbox.Check(true, true);
        //Execute test as step

    All the best,
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top