Skip to content

Commit addad02

Browse files
committed
Update the set_value() method
1 parent 06f9286 commit addad02

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,18 +1058,25 @@ def convert_to_css_selector(self, selector, by):
10581058

10591059
def set_value(self, selector, new_value, by=By.CSS_SELECTOR,
10601060
timeout=settings.LARGE_TIMEOUT):
1061-
""" This method uses jQuery to update a text field. """
1061+
""" This method uses jQuery to update a text field.
1062+
Similar to jquery_update_text_value(), but the element
1063+
doesn't need to be officially visible to work. """
10621064
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
10631065
timeout = self._get_new_timeout(timeout)
10641066
if page_utils.is_xpath_selector(selector):
10651067
by = By.XPATH
1068+
orginal_selector = selector
10661069
selector = self.convert_to_css_selector(selector, by=by)
10671070
self._demo_mode_highlight_if_active(selector, by)
10681071
self.scroll_to(selector, by=by, timeout=timeout)
10691072
value = json.dumps(new_value)
10701073
selector = self._make_css_match_first_element_only(selector)
10711074
set_value_script = """jQuery('%s').val(%s)""" % (selector, value)
10721075
self.safe_execute_script(set_value_script)
1076+
if new_value.endswith('\n'):
1077+
element = self.wait_for_element_present(
1078+
orginal_selector, by=by, timeout=timeout)
1079+
element.send_keys(Keys.RETURN)
10731080
self._demo_mode_pause_if_active()
10741081

10751082
def jquery_update_text_value(self, selector, new_value, by=By.CSS_SELECTOR,

0 commit comments

Comments
 (0)