I have an html table that displays roughly 20 true/false questions on each page. I have a loop running to randomly answer each question. Once the questions are completed on the page, a button is popped to proceed to the next page. There are probably 20 pages though. Rather than repeat the same step over and over (specflow), I would like to create a nested loop but I have not been able to get it working.
An example of what I have tried. This will increment the tr so it lands on each question and randomly answer. I have then tried to do a bool on an element to see if the next questions are there but I am getting lost on the nested loop so that it iterates through all pages. Suggestions?
for (int i = 0; i < count; i++)
{
var rand = Faker.RandomNumber.Next(0, 1).ToString();
if (rand == "0")
{
Browser.FindElement_byXPath(string.Format("//table[@class='table']//tr[{0}]//td[@class='classy']/label/input[@value= 'T']", i + 1)).Click();
}
else
{
Browser.FindElement_byXPath(string.Format("//table[@class='table']//tr[{0}]//td[@class='classy']/label/input[@value= 'F']", i + 1)).Click();
}
}
then continue to the next page
table ex:
<table class="table">
<tbody><tr class="myClass">
<td>1.
</td>
<td>I Like Ducks?
</td>
<td class="classy"><label><input type="radio" name="Q1" value="T" checked="checked"> True</label> <label><input type="radio" name="Q1" value="F"> False</label>
</td>
</tr>
<tr class="myClass">
<td>2.
</td>
<td>I Like Cars?
</td>
<td class="classy"><label><input type="radio" name="Q2" value="T"> True</label> <label><input type="radio" name="Q2" value="F"> False</label>
</td>
</tr>
</tbody></table>
<br>
<button type="submit" class="btn btn-primary pull-right">
Continue <span class="classless"></span>
</button>