Commit 19513e41 by JonahStanley

Refactored all clicks to use the css_click method

parent 9a5326bc
...@@ -115,7 +115,7 @@ def clickActionLink(checklist, task, actionText): ...@@ -115,7 +115,7 @@ def clickActionLink(checklist, task, actionText):
# text will be empty initially, wait for it to populate # text will be empty initially, wait for it to populate
def verify_action_link_text(driver): def verify_action_link_text(driver):
return action_link.text == actionText return world.css_text('#course-checklist' + str(checklist) + ' a', index=task) == actionText
world.wait_for(verify_action_link_text) world.wait_for(verify_action_link_text)
action_link.click() world.css_click('#course-checklist' + str(checklist) + ' a', index=task)
...@@ -9,14 +9,14 @@ from selenium.webdriver.common.keys import Keys ...@@ -9,14 +9,14 @@ from selenium.webdriver.common.keys import Keys
def go_to_static(_step): def go_to_static(_step):
menu_css = 'li.nav-course-courseware' menu_css = 'li.nav-course-courseware'
static_css = 'li.nav-course-courseware-pages' static_css = 'li.nav-course-courseware-pages'
world.css_find(menu_css).click() world.css_click(menu_css)
world.css_find(static_css).click() world.css_click(static_css)
@step(u'I add a new page') @step(u'I add a new page')
def add_page(_step): def add_page(_step):
button_css = 'a.new-button' button_css = 'a.new-button'
world.css_find(button_css).click() world.css_click(button_css)
@step(u'I should( not)? see a "([^"]*)" static page$') @step(u'I should( not)? see a "([^"]*)" static page$')
...@@ -33,13 +33,13 @@ def click_edit_delete(_step, edit_delete, page): ...@@ -33,13 +33,13 @@ def click_edit_delete(_step, edit_delete, page):
button_css = 'a.%s-button' % edit_delete button_css = 'a.%s-button' % edit_delete
index = get_index(page) index = get_index(page)
assert index != -1 assert index != -1
world.css_find(button_css)[index].click() world.css_click(button_css, index=index)
@step(u'I change the name to "([^"]*)"$') @step(u'I change the name to "([^"]*)"$')
def change_name(_step, new_name): def change_name(_step, new_name):
settings_css = '#settings-mode' settings_css = '#settings-mode'
world.css_find(settings_css).click() world.css_click(settings_css)
input_css = 'input.setting-input' input_css = 'input.setting-input'
name_input = world.css_find(input_css) name_input = world.css_find(input_css)
old_name = name_input.value old_name = name_input.value
...@@ -47,7 +47,7 @@ def change_name(_step, new_name): ...@@ -47,7 +47,7 @@ def change_name(_step, new_name):
name_input._element.send_keys(Keys.END, Keys.BACK_SPACE) name_input._element.send_keys(Keys.END, Keys.BACK_SPACE)
name_input._element.send_keys(new_name) name_input._element.send_keys(new_name)
save_button = 'a.save-button' save_button = 'a.save-button'
world.css_find(save_button).click() world.css_click(save_button)
def get_index(name): def get_index(name):
......
...@@ -16,23 +16,23 @@ HTTP_PREFIX = "http://localhost:8001" ...@@ -16,23 +16,23 @@ HTTP_PREFIX = "http://localhost:8001"
def go_to_uploads(_step): def go_to_uploads(_step):
menu_css = 'li.nav-course-courseware' menu_css = 'li.nav-course-courseware'
uploads_css = 'li.nav-course-courseware-uploads' uploads_css = 'li.nav-course-courseware-uploads'
world.css_find(menu_css).click() world.css_click(menu_css)
world.css_find(uploads_css).click() world.css_click(uploads_css)
@step(u'I upload the file "([^"]*)"$') @step(u'I upload the file "([^"]*)"$')
def upload_file(_step, file_name): def upload_file(_step, file_name):
upload_css = 'a.upload-button' upload_css = 'a.upload-button'
world.css_find(upload_css).click() world.css_click(upload_css)
file_css = 'input.file-input' file_css = 'input.file-input'
upload = world.css_find(file_css) upload = world.css_click(file_css)
#uploading the file itself #uploading the file itself
path = os.path.join(TEST_ROOT, 'uploads/', file_name) path = os.path.join(TEST_ROOT, 'uploads/', file_name)
upload._element.send_keys(os.path.abspath(path)) upload._element.send_keys(os.path.abspath(path))
close_css = 'a.close-button' close_css = 'a.close-button'
world.css_find(close_css).click() world.css_click(close_css)
@step(u'I should( not)? see the file "([^"]*)" was uploaded$') @step(u'I should( not)? see the file "([^"]*)" was uploaded$')
......
...@@ -153,16 +153,16 @@ def click_link(partial_text): ...@@ -153,16 +153,16 @@ def click_link(partial_text):
@world.absorb @world.absorb
def css_text(css_selector): def css_text(css_selector, index=0):
# Wait for the css selector to appear # Wait for the css selector to appear
if world.is_css_present(css_selector): if world.is_css_present(css_selector):
try: try:
return world.browser.find_by_css(css_selector).first.text return world.browser.find_by_css(css_selector)[index].text
except StaleElementReferenceException: except StaleElementReferenceException:
# The DOM was still redrawing. Wait a second and try again. # The DOM was still redrawing. Wait a second and try again.
world.wait(1) world.wait(1)
return world.browser.find_by_css(css_selector).first.text return world.browser.find_by_css(css_selector)[index].text
else: else:
return "" return ""
......
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