edx/edx-platform — pull request #228 by JonahStanley (2013-06-20 17:12:06+00:00)
Title: Jonahstanley/fix flakey tests

Suggested Reviewers: @jzoldak @nedbat and anyone else who was having a flakey results from: show answer, navigation tests, stale element reference exception in checking multiple choice. Please run fasttest_acceptance_lms a few times to see if it makes a difference. I have run it ~10-15 times and haven't gotten any breaks so at the very worst, it is no less flakey than what we have.

These commits should fix the flakey tests outlined above. This was accomplished by making the following changes:

1. The problem: There was a flakey test in checking the text of the show/hide answer button
The proposed theory: It was checking the text of the button too quickly.
The proposed fix: I changed the show answer text to instead assert if the text is present or not. While this widens the scope of search, it was the most reliable way of adding in the implicit wait time that splinter allows.

2. The problem: Two of the navigation tests involving clicking a section were failing
The proposed theory: During the jQuery accordion animation, the element is findable but not clickable thus we need to wait.
The proposed fix: jQuery changes the class of the active part of the accordian. Now the css is using these extra classes/attributes so selenium should only be attempting to click the element when it is indeed active and ready

3. The problem: A random stale element reference exception when checking a multiple choice box
The proposed theory: Not sure besides just weird flakiness with stale elements and I haven't ever reproduced this
The proposed fix: A new function called css_check that works exactly like css_click except with checking a box instead of clicking. This allows for the introduction of retrying when there is this exception. As such, inputfield now returns a css selector that can be passed into css_check instead of a web element.