I have a scenario like, answering a multiple choice question. I need to answer the 1st question with 1st option, 2nd question with the 2nd option and so on.. in round robin fashion. Any suggestion, how can I perform using selenium Geb ?
I have written the code for selecting multiple choice and selecting randomly but now I need to select the answer in round robin fashion.
I'm using below code :
def answerQuestions(numQuestions, numAnswers, sectionName) {
for(int i = 0; i < numQuestions; i++) {
log.info(" ${bookingcode}\t"+sectionName+": "+ i)
//I need to select the 1st option for 1 st question instead random
def index = rand.nextInt(numAnswers)
doThink()
waitFor {
cover.displayed == false
mcQuestions*.displayed
clickHammer(mcQuestions[index])
mcQuestions[index].value() != null
nextButton.displayed
}
nextButton.click()
}
}