Commit e337292b by Jay Zoldak

Fix existing advanced settings lettuce tests.

parent c10dc838
...@@ -45,30 +45,37 @@ def create_new_entries(step): ...@@ -45,30 +45,37 @@ def create_new_entries(step):
def they_are_alphabetized(step): def they_are_alphabetized(step):
assert_policy_entries(["a", "display_name", "z"], ['"zebra"', '"Robot Super Course"', '"apple"']) assert_policy_entries(["a", "display_name", "z"], ['"zebra"', '"Robot Super Course"', '"apple"'])
@step('I create a JSON object$') @step('I create a JSON object$')
def create_JSON_object(step): def create_JSON_object(step):
create_entry("json", '{"key": "value", "key_2": "value_2"}') create_entry("json", '{"key": "value", "key_2": "value_2"}')
click_save() click_save()
@step('it is displayed as formatted$') @step('it is displayed as formatted$')
def it_is_formatted(step): def it_is_formatted(step):
assert_policy_entries(["display_name", "json"], ['"Robot Super Course"', '{\n "key": "value",\n "key_2": "value_2"\n}']) assert_policy_entries(["display_name", "json"], ['"Robot Super Course"', '{\n "key": "value",\n "key_2": "value_2"\n}'])
# TODO: this is copied from terrain's step.py. Need to figure out how to share that code. # TODO: this is copied from terrain's step.py. Need to figure out how to share that code.
@step('I reload the page$') @step('I reload the page$')
def reload_the_page(step): def reload_the_page(step):
world.browser.reload() world.browser.reload()
def create_entry(key, value): def create_entry(key, value):
css_click_at('a.new-advanced-policy-item') # Scroll down the page so the button is visible
newKey = css_find('#__new_advanced_key__ input').first world.scroll_to_bottom()
newKey.fill(key) css_click_at('a.new-advanced-policy-item', 10, 10)
new_key_css = 'div#__new_advanced_key__ input'
new_key_element = css_find(new_key_css).first
new_key_element.fill(key)
# For some reason have to get the instance for each command (get error that it is no longer attached to the DOM) # For some reason have to get the instance for each command (get error that it is no longer attached to the DOM)
# Have to do all this because Selenium has a bug that fill does not remove existing text # Have to do all this because Selenium has a bug that fill does not remove existing text
css_find('.CodeMirror textarea').last.double_click() new_value_css = 'div.CodeMirror textarea'
css_find('.CodeMirror textarea').last._element.send_keys(Keys.BACK_SPACE) css_find(new_value_css).last.fill("")
css_find('.CodeMirror textarea').last._element.send_keys(Keys.BACK_SPACE) css_find(new_value_css).last._element.send_keys(Keys.DELETE, Keys.DELETE)
css_find('.CodeMirror textarea').last.fill(value) css_find(new_value_css).last.fill(value)
def delete_entry(index): def delete_entry(index):
...@@ -91,11 +98,12 @@ def assert_entries(css, expected_values): ...@@ -91,11 +98,12 @@ def assert_entries(css, expected_values):
assert_equal(len(expected_values), len(webElements)) assert_equal(len(expected_values), len(webElements))
# Sometimes get stale reference if I hold on to the array of elements # Sometimes get stale reference if I hold on to the array of elements
for counter in range(len(expected_values)): for counter in range(len(expected_values)):
assert_equal(expected_values[counter], css_find(css)[counter].value) assert_equal(expected_values[counter], css_find(css)[counter].value)
def click_save(): def click_save():
css = ".save-button" css = ".save-button"
def is_shown(driver): def is_shown(driver):
visible = css_find(css).first.visible visible = css_find(css).first.visible
if visible: if visible:
......
...@@ -11,6 +11,7 @@ logger = getLogger(__name__) ...@@ -11,6 +11,7 @@ logger = getLogger(__name__)
########### STEP HELPERS ############## ########### STEP HELPERS ##############
@step('I (?:visit|access|open) the Studio homepage$') @step('I (?:visit|access|open) the Studio homepage$')
def i_visit_the_studio_homepage(step): def i_visit_the_studio_homepage(step):
# To make this go to port 8001, put # To make this go to port 8001, put
...@@ -50,6 +51,7 @@ def i_have_opened_a_new_course(step): ...@@ -50,6 +51,7 @@ def i_have_opened_a_new_course(step):
####### HELPER FUNCTIONS ############## ####### HELPER FUNCTIONS ##############
def create_studio_user( def create_studio_user(
uname='robot', uname='robot',
email='robot+studio@edx.org', email='robot+studio@edx.org',
......
...@@ -108,6 +108,11 @@ def i_am_an_edx_user(step): ...@@ -108,6 +108,11 @@ def i_am_an_edx_user(step):
#### helper functions #### helper functions
@world.absorb
def scroll_to_bottom():
# Maximize the browser
world.browser.execute_script("window.scrollTo(0, screen.height);")
@world.absorb @world.absorb
def create_user(uname): def create_user(uname):
......
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