MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase / add_text

Method add_text

seleniumbase/fixtures/base_case.py:1017–1095  ·  view source on GitHub ↗

The more-reliable version of driver.send_keys() Similar to update_text(), but won't clear the text field first.

(self, selector, text, by="css selector", timeout=None)

Source from the content-addressed store, hash-verified

1015 self.__slow_mode_pause_if_active()
1016
1017 def add_text(self, selector, text, by="css selector", timeout=None):
1018 """The more-reliable version of driver.send_keys()
1019 Similar to update_text(), but won't clear the text field first."""
1020 self.__check_scope()
1021 if not timeout:
1022 timeout = settings.LARGE_TIMEOUT
1023 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
1024 timeout = self.__get_new_timeout(timeout)
1025 selector, by = self.__recalculate_selector(selector, by)
1026 if self.__is_cdp_swap_needed():
1027 self.cdp.send_keys(selector, text)
1028 return
1029 if self.__is_shadow_selector(selector):
1030 self.__shadow_type(selector, text, timeout, clear_first=False)
1031 return
1032 if selector == "html" and text in ["\n", Keys.ENTER, Keys.RETURN]:
1033 # This is a shortcut for calling self.click_active_element().
1034 # Use after "\t" or Keys.TAB to cycle through elements first.
1035 self.click_active_element()
1036 return
1037 element = self.wait_for_element_present(
1038 selector, by=by, timeout=timeout
1039 )
1040 if (
1041 selector == "html" and text.count("\t") >= 1
1042 and text.count("\n") == 1 and text.endswith("\n")
1043 and text.replace("\t", "").replace("\n", "").replace(" ", "") == ""
1044 ):
1045 # Shortcut to send multiple tabs followed by click_active_element()
1046 self.wait_for_ready_state_complete()
1047 element.send_keys(Keys.TAB * text.count("\t"))
1048 self.click_active_element()
1049 return
1050 self.__demo_mode_highlight_if_active(selector, by)
1051 if not self.demo_mode and not self.slow_mode:
1052 self.__scroll_to_element(element, selector, by)
1053 pre_action_url = None
1054 if self.demo_mode:
1055 with suppress(Exception):
1056 pre_action_url = self.driver.current_url
1057 text = self.__get_type_checked_text(text)
1058 try:
1059 if not text.endswith("\n"):
1060 element.send_keys(text)
1061 else:
1062 element.send_keys(text[:-1])
1063 if self.slow_mode or self.demo_mode:
1064 self.__demo_mode_pause_if_active(tiny=True)
1065 else:
1066 time.sleep(0.0135)
1067 element.send_keys(Keys.RETURN)
1068 if settings.WAIT_FOR_RSC_ON_PAGE_LOADS:
1069 self.wait_for_ready_state_complete()
1070 except (Stale_Exception, ENI_Exception):
1071 self.wait_for_ready_state_complete()
1072 time.sleep(0.16)
1073 element = self.wait_for_element_visible(
1074 selector, by=by, timeout=timeout

Callers 15

send_keysMethod · 0.95
add_textFunction · 0.80
tekst_toevoegenMethod · 0.80
ajouter_texteMethod · 0.80
aggiungi_testoMethod · 0.80
agregar_textoMethod · 0.80
텍스트를_추가Method · 0.80
テキストを追加Method · 0.80
添加文本Method · 0.80
adicionar_textoMethod · 0.80
test_tinymceMethod · 0.80

Calls 15

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
__is_shadow_selectorMethod · 0.95
__shadow_typeMethod · 0.95
click_active_elementMethod · 0.95
__scroll_to_elementMethod · 0.95

Tested by 4

test_tinymceMethod · 0.64
test_tinymceMethod · 0.64
test_tinymceMethod · 0.64