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

Iterate through DOM objects

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ghandi
Top achievements
Rank 1
Ghandi asked on 16 Apr 2013, 11:18 AM
Hi, 

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

Thanks,
Ghandi

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 18 Apr 2013, 03:01 PM
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
    ExecuteTest("CommonCheckboxSteps");        
}


All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Ghandi
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or