Using Selenium on WordPress Quizzes

I was working on a page tester with Selenium Webdriver for Python and ran into a particular problem. At one point I have what is basically a multiple choice quiz, on which I want to try to do random answers over and over until I finish the quiz on its own. I have no limitation on how many times the code can try to do the quiz, or any sort of captcha.

The problem arises on the fact that this quiz changes dynamically. The quiz plugin can be found here (if you'd like to see some of the quiz's code)

This is the code I have tried to use:

wait =WebDriverWait(driver, wait)
element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'wpProQuiz_questionInput')))
answers = driver.find_elements_by_xpath("//input[@class='wpProQuiz_questionInput'][1]")

and it works well, but only for the first question. Then I proceed to click on the "next" button

next_btn = driver.find_element_by_name("next")

which also works, but when the loop starts again, and tries to find wpProQuiz_questionInput again, it gives me a time out exception because it doesn't find the item.

I'm not sure if I have to somehow tell selenium that the quiz has been updated, or to somehow listen for it. Restarting the page causes the quiz to restart as well.

Thank you, let me know if there's more information I can give to help you help me!


After the comment showing me that all questions are on list form.

Very useful info, thank you. However I still run into some trouble.

        wait = WebDriverWait(driver, 10)

        print "Waiting for quiz to be visible"
        element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'wpProQuiz_list')))
        questions = driver.find_elements_by_xpath("//ol[@class='wpProQuiz_list'][1]")
        print questions
        print "printed questions"
        for question in questions:
                print "trying to find answers"
                answers = question.find_elements_by_tag_name("input")
                print "Answers:"
                print answers
            except Exception as e:
                print "Error: ", e

                next_btn = driver.find_element_by_name("next")

                end_btn = driver.find_element_by_name("endQuizSummary")

I make the program wait for long enough until the elements are visible, but it seems that Selenium doesn't realize that the elements that were hidden, are now visible.