@@ -7439,16 +7439,48 @@ def jquery_update_text(
7439
7439
self.__demo_mode_highlight_if_active(selector, by)
7440
7440
self.scroll_to(selector, by=by)
7441
7441
selector = self.convert_to_css_selector(selector, by=by)
7442
+ css_selector = selector
7442
7443
selector = self.__make_css_match_first_element_only(selector)
7443
7444
selector = self.__escape_quotes_if_needed(selector)
7444
7445
text = re.escape(text)
7445
7446
text = self.__escape_quotes_if_needed(text)
7446
7447
update_text_script = """jQuery('%s').val('%s');""" % (selector, text)
7448
+ if self.recorder_mode and self.__current_url_is_recordable():
7449
+ if self.get_session_storage_item("pause_recorder") == "no":
7450
+ time_stamp = self.execute_script("return Date.now();")
7451
+ origin = self.get_origin()
7452
+ sel_tex = [css_selector, text]
7453
+ action = ["jq_ty", sel_tex, origin, time_stamp]
7454
+ self.__extra_actions.append(action)
7447
7455
self.safe_execute_script(update_text_script)
7448
7456
if text.endswith("\n"):
7449
- element.send_keys("\n")
7457
+ element = self.wait_for_element_present(
7458
+ original_selector, by=original_by, timeout=0.2
7459
+ )
7460
+ element.send_keys(Keys.RETURN)
7461
+ else:
7462
+ try:
7463
+ element = self.wait_for_element_present(
7464
+ original_selector, by=original_by, timeout=0.2
7465
+ )
7466
+ element.send_keys(" " + Keys.BACK_SPACE)
7467
+ except Exception:
7468
+ pass
7450
7469
self.__demo_mode_pause_if_active()
7451
7470
7471
+ def jquery_type(self, selector, text, by="css selector", timeout=None):
7472
+ """Same as self.jquery_update_text()
7473
+ JQuery is used to update a text field.
7474
+ Performs jQuery(selector).val(text); and triggers event listeners.
7475
+ If text ends in "\n", presses RETURN after."""
7476
+ self.__check_scope()
7477
+ if not timeout:
7478
+ timeout = settings.LARGE_TIMEOUT
7479
+ if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
7480
+ timeout = self.__get_new_timeout(timeout)
7481
+ selector, by = self.__recalculate_selector(selector, by)
7482
+ self.jquery_update_text(selector, text, by=by, timeout=timeout)
7483
+
7452
7484
def get_value(self, selector, by="css selector", timeout=None):
7453
7485
"""This method uses JavaScript to get the value of an input field.
7454
7486
(Works on both input fields and textarea fields.)"""
0 commit comments