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)
| 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() |
no test coverage detected