Restore set_input_value

This commit is contained in:
Ben McMorran
2014-08-04 16:35:54 -04:00
committed by cahrens
parent 206e4a954d
commit 91c1fa0207
2 changed files with 17 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ from selenium.webdriver.common.keys import Keys
from .course_page import CoursePage from .course_page import CoursePage
from .container import ContainerPage from .container import ContainerPage
from .utils import set_input_value_and_save, click_css, confirm_prompt from .utils import set_input_value_and_save, set_input_value, click_css, confirm_prompt
class CourseOutlineItem(object): class CourseOutlineItem(object):
@@ -82,7 +82,7 @@ class CourseOutlineItem(object):
""" """
Enters new_name as the item's display name. Enters new_name as the item's display name.
""" """
set_input_value_and_save(self, self._bounded_selector(self.NAME_INPUT_SELECTOR), new_name) set_input_value(self, self._bounded_selector(self.NAME_INPUT_SELECTOR), new_name)
def change_name(self, new_name): def change_name(self, new_name):
""" """

View File

@@ -127,15 +127,22 @@ def confirm_prompt(page, cancel=False):
click_css(page, confirmation_button_css, require_notification=(not cancel)) click_css(page, confirmation_button_css, require_notification=(not cancel))
def set_input_value(page, css, value):
"""
Sets the text field with the given label (display name) to the specified value.
"""
input_element = page.q(css=css).results[0]
# Click in the input to give it the focus
input_element.click()
# Select all, then input the value
input_element.send_keys(Keys.CONTROL + 'a')
input_element.send_keys(value)
# Return the input_element for chaining
return input_element
def set_input_value_and_save(page, css, value): def set_input_value_and_save(page, css, value):
""" """
Sets the text field with given label (display name) to the specified value, and presses Save. Sets the text field with given label (display name) to the specified value, and presses Save.
""" """
input_element = page.q(css=css).results[0] set_input_value(page, css, value).send_keys(Keys.ENTER)
# Click in the input to give it the focus
action = ActionChains(page.browser).click(input_element)
# Delete all of the characters that are currently there
for _x in range(0, len(input_element.get_attribute('value'))):
action = action.send_keys(Keys.BACKSPACE)
# Send the new text, then hit the enter key so that the change event is triggered).
action.send_keys(value).send_keys(Keys.ENTER).perform()