Commit 5411fc76 by Will Daly

Refactored lettuce test of capa problems to use

world.css_click() helper instead of directly
calling splinter.
parent 28674761
...@@ -9,6 +9,7 @@ from bs4 import BeautifulSoup ...@@ -9,6 +9,7 @@ from bs4 import BeautifulSoup
import time import time
import re import re
import os.path import os.path
from selenium.common.exceptions import WebDriverException
from logging import getLogger from logging import getLogger
logger = getLogger(__name__) logger = getLogger(__name__)
...@@ -214,3 +215,15 @@ def save_the_course_content(path='/tmp'): ...@@ -214,3 +215,15 @@ def save_the_course_content(path='/tmp'):
f = open('%s/%s' % (path, filename), 'w') f = open('%s/%s' % (path, filename), 'w')
f.write(output) f.write(output)
f.close f.close
@world.absorb
def css_click(css_selector):
try:
world.browser.find_by_css(css_selector).click()
except WebDriverException:
# Occassionally, MathJax or other JavaScript can cover up
# an element temporarily.
# If this happens, wait a second, then try again
time.sleep(1)
world.browser.find_by_css(css_selector).click()
from lettuce import world, step from lettuce import world, step
from lettuce.django import django_url from lettuce.django import django_url
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import WebDriverException
import random import random
import textwrap import textwrap
import time import time
...@@ -208,20 +206,12 @@ def answer_problem(step, problem_type, correctness): ...@@ -208,20 +206,12 @@ def answer_problem(step, problem_type, correctness):
@step(u'I check a problem') @step(u'I check a problem')
def check_problem(step): def check_problem(step):
try: world.css_click("input.check")
world.browser.find_by_css("input.check").click()
except WebDriverException:
# Occassionally, MathJax or other JavaScript can cover up
# the 'Check' input temporarily.
# If this happens, wait a second, then try again
time.sleep(1)
world.browser.find_by_css("input.check").click()
@step(u'I reset the problem') @step(u'I reset the problem')
def reset_problem(step): def reset_problem(step):
world.browser.find_by_css('input.reset').click() world.css_click('input.reset')
@step(u'My "([^"]*)" answer is marked "([^"]*)"') @step(u'My "([^"]*)" answer is marked "([^"]*)"')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment