MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / js_update_text

Method js_update_text

seleniumbase/fixtures/base_case.py:9167–9185  ·  view source on GitHub ↗

JavaScript + send_keys are used to update a text field. Performs self.set_value() and triggers event listeners. If text ends in "\n", set_value() presses RETURN after. Works faster than send_keys() alone due to the JS call.

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

Source from the content-addressed store, hash-verified

9165 time.sleep(0.04)
9166
9167 def js_update_text(self, selector, text, by="css selector", timeout=None):
9168 """JavaScript + send_keys are used to update a text field.
9169 Performs self.set_value() and triggers event listeners.
9170 If text ends in "\n", set_value() presses RETURN after.
9171 Works faster than send_keys() alone due to the JS call."""
9172 self.__check_scope()
9173 if not timeout:
9174 timeout = settings.LARGE_TIMEOUT
9175 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
9176 timeout = self.__get_new_timeout(timeout)
9177 selector, by = self.__recalculate_selector(selector, by)
9178 text = self.__get_type_checked_text(text)
9179 self.set_value(selector, text, by=by, timeout=timeout)
9180 if not text.endswith("\n"):
9181 with suppress(Exception):
9182 element = page_actions.wait_for_element_present(
9183 self.driver, selector, by, timeout=0.2
9184 )
9185 element.send_keys(" " + Keys.BACK_SPACE)
9186
9187 def js_type(self, selector, text, by="css selector", timeout=None):
9188 """Same as self.js_update_text()

Callers 12

js_typeMethod · 0.95
set_textMethod · 0.95
set_text_contentMethod · 0.95
js_tekst_bijwerkenMethod · 0.80
js_modifier_texteMethod · 0.80
js_aggiornare_testoMethod · 0.80
js_actualizar_textoMethod · 0.80
JS更新文本Method · 0.80
js_atualizar_textoMethod · 0.80

Calls 7

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
set_valueMethod · 0.95
send_keysMethod · 0.45

Tested by

no test coverage detected