-2

I've been struggling with this issue for quite some time now. Basically I want to automate a multiple choice test with 60 questions that has 4 radio types per question. The ID is static ;however the value changes for each option. I have coded a loop to handle the 60 questions ,and I want to click on the first radio option for every question ;however since the value changes dynamically it only works for the 1st question. Please help

HTML

<input data-val="true" data-val-number="The field AnswerId must be a number." id="examResult_AnswerId" name="examResult.AnswerId" type="radio" value="62">

while count < 59:

 q1 = browser.find_element_by_id('examResult_AnswerId')
 q1.send_keys(62)
 q1 = browser.find_element_by_id('btnNext')
 q1.click()
 count += 1

HTML Code for test i want to automate

My Python code

Trev93
  • 1
  • 1

1 Answers1

0

I'm not sure about it, but I think that you would be able to use the find_elements_by_name('examResult.AnswerId') function which would return you a list of all the elements with the name 'examResult.AnswerId' in a list and then iterate over this list. Although it would be better if the elements had different id's, but I think this way will also do the job.

v100ev
  • 176
  • 5