     checkForMissingExercises = =>
       # Wait until the book has loaded.
       @addTimeout(60)
-      wait(@).for(css: '.page-wrapper .page.has-html')
       wait(@).click(css: '.menu-toggle')
 
       doneLoading = =>

SERVER_URL = process.env['SERVER_URL'] or 'http://localhost:3001/'
TEACHER_USERNAME = 'teacher01'

SECTIONS_TO_TEST = 10

describe 'Reference Book Exercises', ->



      for i in [1..SECTIONS_TO_TEST]
        # Selenium sometimes keeps pressing the same next button (doneLoading doesn't seem to work 100%)
        @driver.findElement(css: 'a.page-navigation.next').getAttribute('href').then (oldHref) =>
          @addTimeout(3)

          @driver.findElement(css: 'a.page-navigation.next').click()

          @driver.wait(doneLoading)
          # @driver.findElement(css: 'a.page-navigation.next').getAttribute('href').then (foo) =>
          #   console.log 'new ashkd', foo

          checkPageChanged = =>
            @driver.findElement(css: 'a.page-navigation.next').getAttribute('href').then (newHref) =>
              newHref isnt oldHref

          ifPageDidntChange = =>
            @addTimeout(3)
            console.log 'Page did not change. reclicking.'
            @driver.findElement(css: 'a.page-navigation.next').click()
            @driver.wait(doneLoading)

          @driver.wait(checkPageChanged, 1000).then(null, ifPageDidntChange)
