From 471abb8c28dc166653b1e032a1b68bdf79a5077e Mon Sep 17 00:00:00 2001 From: Jesse Zoldak Date: Fri, 31 Oct 2014 11:47:15 -0400 Subject: [PATCH] Fix lettuce css_fill method for devstack --- common/djangoapps/terrain/ui_helpers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 09028a7fc5..224aacc005 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -526,7 +526,23 @@ def css_fill(css_selector, text, index=0): Then for synchronization purposes, wait for the value on the page. """ wait_for_visible(css_selector, index=index) - retry_on_exception(lambda: css_find(css_selector)[index].fill(text)) + + # HACK: + # At some point, in devstack strings were no longer being filled into fields + # correctly under our original implementation which used splinter's fill method. + # Instead everything after certain letters (E.g. e and r) was getting truncated. + # + # Note that troubleshooting showed that this happened both with the splinter "fill" + # method, and directly with its underlying selenium implementation which is + # self._element.clear() followed by self._element.send_keys(value) + # + # As a workaround, wait for the element to be visible, then use JS to set its value. + retry_on_exception(lambda: css_find(css_selector)[index] is not None) + world.browser.driver.execute_script('window.jQuery("{css_selector}").val("{text}");'.format( + css_selector=css_selector, + text=text + )) + wait_for(lambda _: css_has_value(css_selector, text, index=index)) return True