Commit bf6c342d by Sarina Canelake

Fix location.url [LMS-2786]

parent baf0cee0
...@@ -22,7 +22,7 @@ from selenium.common.exceptions import ( ...@@ -22,7 +22,7 @@ from selenium.common.exceptions import (
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from nose.tools import assert_true # pylint: disable=E0611 from nose.tools import assert_true # pylint: disable=no-name-in-module
REQUIREJS_WAIT = { REQUIREJS_WAIT = {
...@@ -306,6 +306,25 @@ def css_has_text(css_selector, text, index=0, strip=False): ...@@ -306,6 +306,25 @@ def css_has_text(css_selector, text, index=0, strip=False):
@world.absorb @world.absorb
def css_contains_text(css_selector, partial_text, index=0):
"""
Return a boolean indicating whether the element with `css_selector`
contains `partial_text`.
If there are multiple elements matching the css selector,
use `index` to indicate which one.
"""
# If we're expecting a non-empty string, give the page
# a chance to fill in text fields.
if partial_text:
wait_for(lambda _: css_text(css_selector, index=index))
actual_text = css_text(css_selector, index=index)
return partial_text in actual_text
@world.absorb
def css_has_value(css_selector, value, index=0): def css_has_value(css_selector, value, index=0):
""" """
Return a boolean indicating whether the element with Return a boolean indicating whether the element with
......
# pylint: disable=C0111
# pylint: disable=W0621
from lettuce import world, steps from lettuce import world, steps
from nose.tools import assert_in, assert_equals, assert_true from nose.tools import assert_in, assert_true # pylint: disable=no-name-in-module
from common import i_am_registered_for_the_course, visit_scenario_item from common import i_am_registered_for_the_course, visit_scenario_item
from problems_setup import add_problem_to_course, answer_problem from problems_setup import add_problem_to_course, answer_problem
...@@ -90,6 +92,7 @@ class ConditionalSteps(object): ...@@ -90,6 +92,7 @@ class ConditionalSteps(object):
assert_true(world.css_visible('.hidden-contents')) assert_true(world.css_visible('.hidden-contents'))
else: else:
assert_true(world.is_css_not_present('.hidden-contents')) assert_true(world.is_css_not_present('.hidden-contents'))
assert_true(world.css_contains_text('.conditional-message', 'must be attempted before this will become visible.')) # sarina
def answer_poll(self, step, answer): def answer_poll(self, step, answer):
r' I answer the conditioned poll "([^"]*)"$' r' I answer the conditioned poll "([^"]*)"$'
...@@ -116,4 +119,4 @@ class ConditionalSteps(object): ...@@ -116,4 +119,4 @@ class ConditionalSteps(object):
return return
ConditionalSteps() ConditionalSteps()
\ No newline at end of file
...@@ -5,11 +5,11 @@ from django.core.urlresolvers import reverse ...@@ -5,11 +5,11 @@ from django.core.urlresolvers import reverse
def _message(reqm, message): def _message(reqm, message):
return message.format(link="<a href={url}>{url_name}</a>".format( return message.format(link="<a href={url}>{url_name}</a>".format(
url = reverse('jump_to', kwargs=dict(course_id=reqm.course_id.to_deprecated_string(), url = reverse('jump_to', kwargs=dict(course_id=reqm.course_id.to_deprecated_string(),
location=reqm.location.url())), location=reqm.location.to_deprecated_string())),
url_name = reqm.display_name_with_default)) url_name = reqm.display_name_with_default))
%> %>
% if message: % if message:
% for reqm in module.required_modules: % for reqm in module.required_modules:
<p>${_message(reqm, message)}</p> <p class="conditional-message">${_message(reqm, message)}</p>
% endfor % endfor
% endif % endif
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